fix: Introduce _get_current_streamed_span() to keep types backwards compatible#6177
Conversation
get_current_streamed_span() to keep types backwards compatible
Codecov Results 📊✅ 13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 7.59s All tests are passing successfully. ❌ Patch coverage is 59.09%. Project has 14939 uncovered lines. Files with missing lines (7)
Generated by Codecov Action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e0824df. Configure here.
sentrivana
left a comment
There was a problem hiding this comment.
TY for untangling the two 🙏🏻
Left two small questions and a comment.
| def get_current_streamed_span( | ||
| scope: "Optional[Scope]" = None, | ||
| ) -> "Optional[StreamedSpan]": | ||
| """ | ||
| Returns the currently active streamed span if there is one running, otherwise `None` | ||
| """ | ||
| return tracing_utils.get_current_streamed_span(scope) |
There was a problem hiding this comment.
I'd not expose this as a public API function, at least while the functionality is experimental. Maybe we can move this to traces.py, or at least prefix it with an underscore.
Would also be good to add more context to the docstring so that users know when this can be used (i.e., only if trace_lifecycle="stream").
There was a problem hiding this comment.
Yes that's a great point, it would be best to not expose too much. I've limited the API surface to _get_current_streamed_span in traces.py and expanded the docstring
get_current_streamed_span() to keep types backwards compatible_get_current_streamed_span() to keep types backwards compatible

…atible
Description
Create streaming-lifecycle variants of the
tracing_utils.get_current_span()function and theScope.spanproperty. 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.spanproperty returnsNoneif aStreamedSpanis held, andScope.streamed_spanreturnsNoneif aSpanis held on the scope.Issues
Closes #6166
Reminders
tox -e linters.feat:,fix:,ref:,meta:)