diff --git a/sentry_sdk/integrations/asgi.py b/sentry_sdk/integrations/asgi.py index 733aa2b3fe..408da16226 100644 --- a/sentry_sdk/integrations/asgi.py +++ b/sentry_sdk/integrations/asgi.py @@ -267,9 +267,11 @@ def event_processor(self, event, hint, asgi_scope): event["request"] = deepcopy(request_data) # Only set transaction name if not already set by Starlette or FastAPI (or other frameworks) - already_set = event["transaction"] != _DEFAULT_TRANSACTION_NAME and event[ - "transaction_info" - ].get("source") in [ + already_set = event.get( + "transaction" + ) != _DEFAULT_TRANSACTION_NAME and event.get("transaction_info", {}).get( + "source" + ) in [ TransactionSource.COMPONENT, TransactionSource.ROUTE, TransactionSource.CUSTOM,