◐ Shell
clean mode source ↗

fix: Introduce `_get_current_streamed_span()` to keep types backwards compatible by alexander-alderman-webb · Pull Request #6177 · getsentry/sentry-python

…atible

Description

Create streaming-lifecycle variants of the tracing_utils.get_current_span() function and the Scope.span property. The existing functions are narrowed to be backwards compatible for users of the transaction-based span lifecycle, allowing users to upgrade their SDK version without their type checkers raising errors.

Note that this breaks all current uses of these functions when the streaming lifecycle option is enabled (which is experimental). All call sites internal to the SDK are updated.

The Scope.span property returns None if a StreamedSpan is held, and Scope.streamed_span returns None if a Span is held on the scope.

Issues

Closes #6166

Reminders