Skip to content

Commit ef68e44

Browse files
committed
.
1 parent e0ddad5 commit ef68e44

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

sentry_sdk/integrations/wsgi.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -311,26 +311,33 @@ def event_processor(event, hint):
311311
return event_processor
312312

313313

314+
ENVIRON_TO_ATTRIBUTE = {
315+
"PATH_INFO": "url.path",
316+
"REQUEST_METHOD": "http.request.method",
317+
"SERVER_NAME": "server.address",
318+
"SERVER_PORT": "server.port",
319+
"url_scheme": "url.scheme",
320+
}
321+
322+
314323
def _prepopulate_attributes(wsgi_environ):
315324
attributes = {}
316325

317-
for attr in (
318-
"CONTENT_LENGTH",
319-
"CONTENT_TYPE",
320-
"PATH_INFO",
321-
"QUERY_STRING",
322-
"REQUEST_METHOD",
323-
"SCRIPT_NAME",
324-
"SERVER_NAME",
325-
"SERVER_PORT",
326-
"SERVER_PROTOCOL",
327-
"multithread",
328-
"multiprocess",
329-
"run_once",
330-
"url_scheme",
331-
"version",
332-
):
333-
if wsgi_environ.get(attr):
334-
attributes[f"wsgi_environ.{attr}"] = wsgi_environ[attr]
326+
for property, attr in ENVIRON_TO_ATTRIBUTE.items():
327+
if wsgi_environ.get(property) is not None:
328+
attributes[attr] = wsgi_environ[property]
329+
330+
if wsgi_environ.get("SERVER_PROTOCOL") is not None:
331+
try:
332+
proto, version = wsgi_environ["SERVER_PROTOCOL"].split("/")
333+
attributes["network.protocol.name"] = proto
334+
attributes["network.protocol.version"] = version
335+
except Exception:
336+
attributes["network.protocol.name"] = wsgi_environ["SERVER_PROTOCOL"]
337+
338+
try:
339+
attributes["url.full"] = ""
340+
except Exception:
341+
pass
335342

336343
return attributes

0 commit comments

Comments
 (0)