Skip to content

Commit b59f3cd

Browse files
committed
move warnings
1 parent 7daa720 commit b59f3cd

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

sentry_sdk/scope.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,15 +1182,6 @@ def start_streamed_span(
11821182
active: bool,
11831183
) -> "StreamedSpan":
11841184
# TODO: rename to start_span once we drop the old API
1185-
if not has_span_streaming_enabled(sentry_sdk.get_client().options):
1186-
warnings.warn(
1187-
"Using span streaming API in non-span-streaming mode. Use "
1188-
"sentry_sdk.start_transaction() and sentry_sdk.start_span() "
1189-
"instead.",
1190-
stacklevel=2,
1191-
)
1192-
return NoOpStreamedSpan()
1193-
11941185
if isinstance(parent_span, NoOpStreamedSpan):
11951186
# parent_span is only set if the user explicitly set it
11961187
logger.debug(

sentry_sdk/traces.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,17 @@ def start_span(
140140
:return: The span that has been started.
141141
:rtype: StreamedSpan
142142
"""
143+
from sentry_sdk.tracing_utils import has_span_streaming_enabled
144+
145+
if not has_span_streaming_enabled(sentry_sdk.get_client().options):
146+
warnings.warn(
147+
"Using span streaming API in non-span-streaming mode. Use "
148+
"sentry_sdk.start_transaction() and sentry_sdk.start_span() "
149+
"instead.",
150+
stacklevel=2,
151+
)
152+
return NoOpStreamedSpan()
153+
143154
return sentry_sdk.get_current_scope().start_streamed_span(
144155
name, attributes, parent_span, active
145156
)

0 commit comments

Comments
 (0)