ref: Introduce _is_sampled_streamed_span() helper to replace repeated check#6180
Open
ericapisani wants to merge 1 commit intomasterfrom
Open
ref: Introduce _is_sampled_streamed_span() helper to replace repeated check#6180ericapisani wants to merge 1 commit intomasterfrom
_is_sampled_streamed_span() helper to replace repeated check#6180ericapisani wants to merge 1 commit intomasterfrom
Conversation
…ed check The `isinstance(span, StreamedSpan) and not isinstance(span, NoOpStreamedSpan)` pattern was scattered across the codebase and easy to get wrong — forgetting the `NoOpStreamedSpan` guard is a recurring code review catch. Extract it into a single `_is_sampled_streamed_span()` helper in `traces.py` with a `TypeGuard[StreamedSpan]` return type for proper type narrowing, and replace all instances of the combined check in `scope.py`, `starlette.py`, and `fastapi.py`.
Member
Author
|
bugbot run |
Member
Author
|
@sentry review |
Contributor
Codecov Results 📊✅ 13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 12.39s All tests are passing successfully. ❌ Patch coverage is 72.73%. Project has 14939 uncovered lines. Files with missing lines (4)
Generated by Codecov Action |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 10e96aa. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
isinstance(span, StreamedSpan) and not isinstance(span, NoOpStreamedSpan)pattern was repeated in multiple places. Omitting theNoOpStreamedSpanguard is a frequent code review catch — it silently treats unsampled spans as sampled.Introduce
_is_sampled_streamed_span()intraces.pywith aTypeGuard[StreamedSpan]return type for proper type narrowing, and replace all combined-check instances inscope.py,starlette.py, andfastapi.py.Locations where
_spancan also be a regularSpan(not justStreamedSpan) were intentionally left unchanged, as the semantics differ there.Fixes PY-2397
Fixes #6182