fix: Introduce _get_current_streamed_span() to keep types backwards compatible
#6177
1 issue
code-review: Found 1 issue (1 medium)
Medium
Transaction active-thread fallback skipped when span streaming is enabled but no streamed span exists - `sentry_sdk/integrations/starlette.py:557-565`
The refactor changes the structure to if span_streaming: ... elif current_scope.transaction is not None:. When span streaming is enabled but current_scope.streamed_span is not a usable StreamedSpan (e.g., it's None or a NoOpStreamedSpan), the inner branch is skipped and the elif is never evaluated, so current_scope.transaction.update_active_thread() is no longer called. Previously the equivalent fallback path executed whenever the streamed span check failed. As a result, profiling thread updates can be silently dropped for sync Starlette requests when streaming is enabled but no streamed span is active.
Duration: 1m 28s · Tokens: 302.1k in / 4.2k out · Cost: $1.57
Annotations
Check warning on line 565 in sentry_sdk/integrations/starlette.py
sentry-warden / warden: code-review
Transaction active-thread fallback skipped when span streaming is enabled but no streamed span exists
The refactor changes the structure to `if span_streaming: ... elif current_scope.transaction is not None:`. When span streaming is enabled but `current_scope.streamed_span` is not a usable `StreamedSpan` (e.g., it's `None` or a `NoOpStreamedSpan`), the inner branch is skipped and the `elif` is never evaluated, so `current_scope.transaction.update_active_thread()` is no longer called. Previously the equivalent fallback path executed whenever the streamed span check failed. As a result, profiling thread updates can be silently dropped for sync Starlette requests when streaming is enabled but no streamed span is active.