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
- Please add tests to validate your changes, and lint your code using
tox -e linters. - Add GH Issue ID & Linear ID (if applicable)
- PR title should use conventional commit style (
feat:,fix:,ref:,meta:) - For external contributors: CONTRIBUTING.md, Sentry SDK development docs, Discord community