◐ Shell
clean mode source ↗

ref: Introduce inline type check for whether a span is StreamedSpan by ericapisani · Pull Request #6180 · getsentry/sentry-python

…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`.

cursor[bot]

alexander-alderman-webb

sentrivana

@ericapisani

cursor[bot]

@ericapisani ericapisani changed the title ref: Introduce _is_sampled_streamed_span() helper to replace repeated check ref: Introduce _is_streamed_span() helper to replace repeated check

May 5, 2026

@ericapisani

alexander-alderman-webb

…ry/sentry-python into create-sampled-span-helper-0doa2

alexander-alderman-webb

@ericapisani ericapisani changed the title ref: Introduce _is_streamed_span() helper to replace repeated check ref: Introduce inline type check for whether a span is StreamedSpan

May 5, 2026

@ericapisani ericapisani deleted the create-sampled-span-helper-0doa2 branch

May 5, 2026 16:18

This was referenced

May 8, 2026