From d39ee129ffc44f62caf916593c42c9aa3a550abe Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Mon, 8 Jun 2026 09:47:45 +0200 Subject: [PATCH] fix(api): Only emit API mismatch warnings when client is active --- sentry_sdk/traces.py | 3 ++- sentry_sdk/tracing_utils.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sentry_sdk/traces.py b/sentry_sdk/traces.py index 317f145116..eaa4c67cb5 100644 --- a/sentry_sdk/traces.py +++ b/sentry_sdk/traces.py @@ -168,7 +168,8 @@ def start_span( """ from sentry_sdk.tracing_utils import has_span_streaming_enabled - if not has_span_streaming_enabled(sentry_sdk.get_client().options): + client = sentry_sdk.get_client() + if client.is_active() and not has_span_streaming_enabled(client.options): warnings.warn( "Using span streaming API in non-span-streaming mode. Use " "sentry_sdk.start_transaction() and sentry_sdk.start_span() " diff --git a/sentry_sdk/tracing_utils.py b/sentry_sdk/tracing_utils.py index e713c7d992..3b44bad0bb 100644 --- a/sentry_sdk/tracing_utils.py +++ b/sentry_sdk/tracing_utils.py @@ -1101,7 +1101,7 @@ def span_decorator(f: "Any") -> "Any": @functools.wraps(f) async def async_wrapper(*args: "Any", **kwargs: "Any") -> "Any": client = sentry_sdk.get_client() - if not has_span_streaming_enabled(client.options): + if client.is_active() and not has_span_streaming_enabled(client.options): warnings.warn( "Using span streaming API in non-span-streaming mode. Use " "@sentry_sdk.trace instead.", @@ -1124,7 +1124,7 @@ async def async_wrapper(*args: "Any", **kwargs: "Any") -> "Any": @functools.wraps(f) def sync_wrapper(*args: "Any", **kwargs: "Any") -> "Any": client = sentry_sdk.get_client() - if not has_span_streaming_enabled(client.options): + if client.is_active() and not has_span_streaming_enabled(client.options): warnings.warn( "Using span streaming API in non-span-streaming mode. Use " "@sentry_sdk.trace instead.",