From d1c693441ae1aca7e65a90c8dcbc7fd856f2aee2 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Tue, 28 Apr 2026 09:45:11 +0200 Subject: [PATCH] fix(httpx): Consistently early-exit when adding request source --- sentry_sdk/tracing_utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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.