File tree Expand file tree Collapse file tree
ext/opentelemetry-ext-wsgi/src/opentelemetry/ext/wsgi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,9 +96,14 @@ def collect_request_attributes(environ):
9696 "http.method" : environ .get ("REQUEST_METHOD" ),
9797 "http.server_name" : environ .get ("SERVER_NAME" ),
9898 "http.scheme" : environ .get ("wsgi.url_scheme" ),
99- "host.port" : int (environ .get ("SERVER_PORT" )),
10099 }
101100
101+ host_port = environ .get ("SERVER_PORT" )
102+ if host_port is not None :
103+ if isinstance (host_port , str ):
104+ host_port = int (host_port )
105+ result .update ({"host.port" : host_port })
106+
102107 setifnotnone (result , "http.host" , environ .get ("HTTP_HOST" ))
103108 target = environ .get ("RAW_URI" )
104109 if target is None : # Note: `"" or None is None`
@@ -151,7 +156,6 @@ def add_response_attributes(
151156def get_default_span_name (environ ):
152157 """Default implementation for name_callback, returns HTTP {METHOD_NAME}."""
153158 return "HTTP {}" .format (environ .get ("REQUEST_METHOD" , "" )).strip ()
154- )
155159
156160
157161class OpenTelemetryMiddleware :
You can’t perform that action at this time.
0 commit comments