From 44c43a8b7446b74f4c2bdf24e2938247fd17f5ac Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sat, 21 Sep 2019 00:39:44 +0200 Subject: [PATCH] fix: Do not attempt to access headers for all asgi requests (#506) * fix: Do not attempt to access headers for all asgi requests * fix: Fix NameError --- sentry_sdk/integrations/asgi.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sentry_sdk/integrations/asgi.py b/sentry_sdk/integrations/asgi.py index 11b8d1caa7..efbbe0ad38 100644 --- a/sentry_sdk/integrations/asgi.py +++ b/sentry_sdk/integrations/asgi.py @@ -68,8 +68,14 @@ async def _run_app(self, scope, callback): ) sentry_scope.add_event_processor(processor) - span = Span.continue_from_headers(dict(scope["headers"])) - span.op = "http.server" + if scope["type"] in ("http", "websocket"): + span = Span.continue_from_headers(dict(scope["headers"])) + span.op = "{}.server".format(scope["type"]) + else: + span = Span() + span.op = "asgi.server" + + span.set_tag("asgi.type", scope["type"]) span.transaction = "generic ASGI request" with hub.start_span(span) as span: