ref: Add streaming trace decorator (7) #5594
2 issues
find-bugs: Found 2 issues (1 medium, 1 low)
Medium
StreamedSpan.__exit__ is no-op, contradicting documented auto-finish behavior - `sentry_sdk/traces.py:237-240`
The __exit__ method added to StreamedSpan is a no-op (pass), but the documentation at line 88 states 'The span automatically finishes once the with block is exited' and the @trace decorator docstring (line 377) says it 'finishes the span when the function returns or raises an exception'. Additionally, unlike the existing Span.__exit__ in tracing.py (lines 396-406), this implementation doesn't set error status on exceptions, doesn't call a finish/end method, and doesn't restore scope state. Users relying on context manager semantics will have spans that never complete.
Low
Docstring references non-existent `op` parameter - `sentry_sdk/traces.py:381`
The docstring example mentions @trace(op="custom") but the trace function in sentry_sdk/traces.py does not accept an op parameter - it only accepts name, attributes, and active. This will confuse users who try to use the documented example. The op parameter exists in the other trace decorator in sentry_sdk/tracing.py but not in this streaming version.
Duration: 4m 33s · Tokens: 1.7M in / 11.2k out · Cost: $2.28 (+merge: $0.00)
Annotations
Check warning on line 240 in sentry_sdk/traces.py
github-actions / warden: find-bugs
StreamedSpan.__exit__ is no-op, contradicting documented auto-finish behavior
The `__exit__` method added to `StreamedSpan` is a no-op (`pass`), but the documentation at line 88 states 'The span automatically finishes once the `with` block is exited' and the `@trace` decorator docstring (line 377) says it 'finishes the span when the function returns or raises an exception'. Additionally, unlike the existing `Span.__exit__` in tracing.py (lines 396-406), this implementation doesn't set error status on exceptions, doesn't call a finish/end method, and doesn't restore scope state. Users relying on context manager semantics will have spans that never complete.