Skip to content

ref: Add streaming trace decorator

941863e
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Merged

ref: Add streaming trace decorator (7) #5594

ref: Add streaming trace decorator
941863e
Select commit
Loading
Failed to load commit list.
GitHub Actions / warden: find-bugs completed Mar 5, 2026 in 3m 14s

2 issues

find-bugs: Found 2 issues (1 high, 1 low)

High

StreamedSpan lacks context manager methods (__enter__/__exit__) causing decorator to fail at runtime - `sentry_sdk/traces.py:350-418`

The new trace decorator at line 350 calls create_streaming_span_decorator which uses start_streaming_span in a with statement (lines 964-966 and 979-982 in tracing_utils.py). However, StreamedSpan (the return type of start_streaming_span) does not implement __enter__ and __exit__ methods. This will cause a TypeError: 'StreamedSpan' object does not support the context manager protocol when any function decorated with @trace (from sentry_sdk.traces) is called.

Also found at:

  • sentry_sdk/tracing_utils.py:964-966

Low

Unused import of should_send_default_pii in create_streaming_span_decorator - `sentry_sdk/tracing_utils.py:953`

The function imports should_send_default_pii from sentry_sdk.scope at line 953, but this function is never used within create_streaming_span_decorator. The non-streaming version (create_span_decorator) uses this import to determine whether to include PII in span attributes, but the streaming version appears incomplete.


Duration: 3m 12s · Tokens: 2.1M in / 11.4k out · Cost: $2.08 (+merge: $0.00)

Annotations

Check failure on line 418 in sentry_sdk/traces.py

See this annotation in the file changed.

@github-actions github-actions / warden: find-bugs

StreamedSpan lacks context manager methods (__enter__/__exit__) causing decorator to fail at runtime

The new `trace` decorator at line 350 calls `create_streaming_span_decorator` which uses `start_streaming_span` in a `with` statement (lines 964-966 and 979-982 in tracing_utils.py). However, `StreamedSpan` (the return type of `start_streaming_span`) does not implement `__enter__` and `__exit__` methods. This will cause a `TypeError: 'StreamedSpan' object does not support the context manager protocol` when any function decorated with `@trace` (from `sentry_sdk.traces`) is called.

Check failure on line 966 in sentry_sdk/tracing_utils.py

See this annotation in the file changed.

@github-actions github-actions / warden: find-bugs

[4SM-ZV7] StreamedSpan lacks context manager methods (__enter__/__exit__) causing decorator to fail at runtime (additional location)

The new `trace` decorator at line 350 calls `create_streaming_span_decorator` which uses `start_streaming_span` in a `with` statement (lines 964-966 and 979-982 in tracing_utils.py). However, `StreamedSpan` (the return type of `start_streaming_span`) does not implement `__enter__` and `__exit__` methods. This will cause a `TypeError: 'StreamedSpan' object does not support the context manager protocol` when any function decorated with `@trace` (from `sentry_sdk.traces`) is called.