diff --git a/sentry_sdk/tracing_utils.py b/sentry_sdk/tracing_utils.py index 82a2e3086c..04fa7696e5 100644 --- a/sentry_sdk/tracing_utils.py +++ b/sentry_sdk/tracing_utils.py @@ -353,11 +353,10 @@ def add_http_request_source( Adds OTel compatible source code information to a span for an outgoing HTTP request """ client = sentry_sdk.get_client() + if not client.is_active(): + return if isinstance(span, LegacySpan): - if not client.is_active(): - return - # In the StreamedSpan case, we need to add the extra span information before # the span finishes, so it's expected that this will be None. In the LegacySpan case, # it should already be finished.