ref: Add warnings to span streaming APIs (10) #5613
1 issue
find-bugs: Found 1 issue (1 medium)
Medium
Double warnings emitted when using streaming span decorator in non-span-streaming mode - `sentry_sdk/tracing_utils.py:962-968`
When create_streaming_span_decorator is used in non-span-streaming mode, it emits a warning in the wrapper, then calls start_streaming_span() (which is sentry_sdk.traces.start_span). The start_span function also checks has_span_streaming_enabled() and emits its own warning. This results in two warnings being shown to the user for a single decorated function call, which is noisy and confusing. The decorator should either return early with an alternative execution path (similar to how traces.start_span returns NoOpStreamedSpan), or the warning should be emitted only in one place.
Duration: 2m 52s · Tokens: 815.0k in / 9.5k out · Cost: $1.81 (+extraction: $0.01, +fix_gate: $0.00)
Annotations
Check warning on line 968 in sentry_sdk/tracing_utils.py
github-actions / warden: find-bugs
Double warnings emitted when using streaming span decorator in non-span-streaming mode
When `create_streaming_span_decorator` is used in non-span-streaming mode, it emits a warning in the wrapper, then calls `start_streaming_span()` (which is `sentry_sdk.traces.start_span`). The `start_span` function also checks `has_span_streaming_enabled()` and emits its own warning. This results in two warnings being shown to the user for a single decorated function call, which is noisy and confusing. The decorator should either return early with an alternative execution path (similar to how `traces.start_span` returns `NoOpStreamedSpan`), or the warning should be emitted only in one place.