@@ -120,7 +120,9 @@ def __call__(self, environ, start_response):
120120 name = DEFAULT_TRANSACTION_NAME ,
121121 source = TRANSACTION_SOURCE_ROUTE ,
122122 origin = self .span_origin ,
123- attributes = _prepopulate_attributes (environ ),
123+ attributes = _prepopulate_attributes (
124+ environ , self .use_x_forwarded_for
125+ ),
124126 )
125127 if should_trace
126128 else nullcontext ()
@@ -313,14 +315,16 @@ def event_processor(event, hint):
313315
314316ENVIRON_TO_ATTRIBUTE = {
315317 "PATH_INFO" : "url.path" ,
318+ "QUERY_STRING" : "url.query" ,
316319 "REQUEST_METHOD" : "http.request.method" ,
317320 "SERVER_NAME" : "server.address" ,
318321 "SERVER_PORT" : "server.port" ,
319- "url_scheme" : "url.scheme" ,
322+ "wsgi. url_scheme" : "url.scheme" ,
320323}
321324
322325
323- def _prepopulate_attributes (wsgi_environ ):
326+ def _prepopulate_attributes (wsgi_environ , use_x_forwarded_for = False ):
327+ """Extract span attributes from the WSGI environment."""
324328 attributes = {}
325329
326330 for property , attr in ENVIRON_TO_ATTRIBUTE .items ():
@@ -336,7 +340,9 @@ def _prepopulate_attributes(wsgi_environ):
336340 attributes ["network.protocol.name" ] = wsgi_environ ["SERVER_PROTOCOL" ]
337341
338342 try :
339- attributes ["url.full" ] = ""
343+ url = get_request_url (wsgi_environ , use_x_forwarded_for )
344+ query = wsgi_environ .get ("QUERY_STRING" )
345+ attributes ["url.full" ] = f"{ url } ?{ query } "
340346 except Exception :
341347 pass
342348
0 commit comments