fix: Introduce _get_current_streamed_span() to keep types backwards compatible
#6177
1 issue
Medium
span.setter silently drops StreamedSpan segment metadata, breaking runtime backwards compatibility - `sentry_sdk/scope.py:887-896`
The previous span.setter accepted Union[Span, StreamedSpan] and, when given a StreamedSpan segment, populated self._transaction and self._transaction_info from the span's name and 'sentry.span.source' attribute. The new span.setter only handles Transaction and silently ignores StreamedSpan inputs at runtime. Although the type annotation is now Optional[Span], existing callers (integrations, user code, third-party code) that still assign a StreamedSpan via scope.span = streamed_span will no longer have transaction metadata populated, causing events to be missing transaction names/sources and breaking segment linkage in streaming mode. The PR's stated goal is backwards compatibility, but this is only type-level — runtime behavior regressed.
4 skills analyzed
| Skill | Findings | Duration | Cost |
|---|---|---|---|
| code-review | 0 | 42.1s | $0.79 |
| find-bugs | 1 | 44.4s | $0.68 |
| skill-scanner | 0 | 13.4s | $0.62 |
| security-review | 0 | 31.8s | $0.45 |
Duration: 2m 12s · Tokens: 482.5k in / 4.9k out · Cost: $2.53 (+dedup: $0.00)