Skip to content

Commit 44c43a8

Browse files
authored
fix: Do not attempt to access headers for all asgi requests (getsentry#506)
* fix: Do not attempt to access headers for all asgi requests * fix: Fix NameError
1 parent da399d6 commit 44c43a8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sentry_sdk/integrations/asgi.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ async def _run_app(self, scope, callback):
6868
)
6969
sentry_scope.add_event_processor(processor)
7070

71-
span = Span.continue_from_headers(dict(scope["headers"]))
72-
span.op = "http.server"
71+
if scope["type"] in ("http", "websocket"):
72+
span = Span.continue_from_headers(dict(scope["headers"]))
73+
span.op = "{}.server".format(scope["type"])
74+
else:
75+
span = Span()
76+
span.op = "asgi.server"
77+
78+
span.set_tag("asgi.type", scope["type"])
7379
span.transaction = "generic ASGI request"
7480

7581
with hub.start_span(span) as span:

0 commit comments

Comments
 (0)