From f6a97f6c689ab6825517bfb9101836d1de72c5ee Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Fri, 20 Sep 2019 16:18:10 +0200 Subject: [PATCH 1/2] fix: Do not attempt to access headers for all asgi requests --- 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..021c76b1f9 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 asgi_scope["type"] in ("http", "websocket"): + span = Span.continue_from_headers(dict(scope["headers"])) + span.op = "{}.server".format(asgi_scope["type"]) + else: + span = Span() + span.op = "asgi.server" + + span.set_tag("asgi.type", asgi_scope["type"]) span.transaction = "generic ASGI request" with hub.start_span(span) as span: From 0e40cad9fc2d13f98052475e011ec1a0669facc7 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Fri, 20 Sep 2019 19:31:06 +0200 Subject: [PATCH 2/2] fix: Fix NameError --- sentry_sdk/integrations/asgi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sentry_sdk/integrations/asgi.py b/sentry_sdk/integrations/asgi.py index 021c76b1f9..efbbe0ad38 100644 --- a/sentry_sdk/integrations/asgi.py +++ b/sentry_sdk/integrations/asgi.py @@ -68,14 +68,14 @@ async def _run_app(self, scope, callback): ) sentry_scope.add_event_processor(processor) - if asgi_scope["type"] in ("http", "websocket"): + if scope["type"] in ("http", "websocket"): span = Span.continue_from_headers(dict(scope["headers"])) - span.op = "{}.server".format(asgi_scope["type"]) + span.op = "{}.server".format(scope["type"]) else: span = Span() span.op = "asgi.server" - span.set_tag("asgi.type", asgi_scope["type"]) + span.set_tag("asgi.type", scope["type"]) span.transaction = "generic ASGI request" with hub.start_span(span) as span: