Skip to content

Commit 701bc00

Browse files
committed
inline all the things
1 parent 203c816 commit 701bc00

4 files changed

Lines changed: 9 additions & 15 deletions

File tree

sentry_sdk/integrations/fastapi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sentry_sdk
77
from sentry_sdk.integrations import DidNotEnable
88
from sentry_sdk.scope import should_send_default_pii
9-
from sentry_sdk.traces import _is_streamed_span
9+
from sentry_sdk.traces import StreamedSpan
1010
from sentry_sdk.tracing import SOURCE_FOR_STYLE, TransactionSource
1111
from sentry_sdk.tracing_utils import has_span_streaming_enabled
1212
from sentry_sdk.utils import transaction_from_function
@@ -95,7 +95,7 @@ def _sentry_call(*args: "Any", **kwargs: "Any") -> "Any":
9595
if has_span_streaming_enabled(client.options):
9696
current_span = current_scope.streamed_span
9797

98-
if _is_streamed_span(current_span):
98+
if type(current_span) is StreamedSpan:
9999
segment = current_span._segment
100100
segment._update_active_thread()
101101

sentry_sdk/integrations/starlette.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
)
2323
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
2424
from sentry_sdk.scope import should_send_default_pii
25-
from sentry_sdk.traces import _get_current_streamed_span, _is_streamed_span
25+
from sentry_sdk.traces import _get_current_streamed_span
26+
from sentry_sdk.traces import StreamedSpan
2627
from sentry_sdk.tracing import (
2728
SOURCE_FOR_STYLE,
2829
TransactionSource,
@@ -255,7 +256,7 @@ def _set_request_body_data_on_streaming_segment(
255256
info: "Optional[Dict[str, Any]]",
256257
) -> None:
257258
current_span = _get_current_streamed_span()
258-
if info and "data" in info and _is_streamed_span(current_span):
259+
if info and "data" in info and type(current_span) is StreamedSpan:
259260
with capture_internal_exceptions():
260261
current_span._segment.set_attribute(
261262
"http.request.body.data",
@@ -552,7 +553,7 @@ def _sentry_sync_func(*args: "Any", **kwargs: "Any") -> "Any":
552553
if span_streaming:
553554
current_span = current_scope.streamed_span
554555

555-
if _is_streamed_span(current_span):
556+
if type(current_span) is StreamedSpan:
556557
current_span._segment._update_active_thread()
557558
elif current_scope.transaction is not None:
558559
current_scope.transaction.update_active_thread()

sentry_sdk/scope.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
_DEFAULT_PARENT_SPAN,
3232
NoOpStreamedSpan,
3333
StreamedSpan,
34-
_is_streamed_span,
3534
)
3635
from sentry_sdk.tracing import (
3736
BAGGAGE_HEADER_NAME,
@@ -588,7 +587,7 @@ def get_traceparent(self, *args: "Any", **kwargs: "Any") -> "Optional[str]":
588587

589588
span_streaming = has_span_streaming_enabled(client.options)
590589
# If we have an active span, return traceparent from there
591-
if span_streaming and _is_streamed_span(self.streamed_span):
590+
if span_streaming and type(self.streamed_span) is StreamedSpan:
592591
return self.streamed_span._to_traceparent()
593592
elif not span_streaming and self.span is not None:
594593
return self.span._to_traceparent()
@@ -608,7 +607,7 @@ def get_baggage(self, *args: "Any", **kwargs: "Any") -> "Optional[Baggage]":
608607

609608
span_streaming = has_span_streaming_enabled(client.options)
610609
# If we have an active span, return baggage from there
611-
if span_streaming and _is_streamed_span(self.streamed_span):
610+
if span_streaming and type(self.streamed_span) is StreamedSpan:
612611
return self.streamed_span._to_baggage()
613612
elif not span_streaming and self.span is not None:
614613
return self.span._to_baggage()
@@ -913,7 +912,7 @@ def streamed_span(self, span: "Optional[StreamedSpan]") -> None:
913912

914913
# Also set _transaction and _transaction_info in streaming mode as this
915914
# is used for populating events and linking them to segments
916-
if _is_streamed_span(span) and span._is_segment():
915+
if type(span) is StreamedSpan and span._is_segment():
917916
self._transaction = span.name
918917
if span._attributes.get("sentry.span.source"):
919918
self._transaction_info["source"] = str(

sentry_sdk/traces.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
Iterator,
3838
Optional,
3939
ParamSpec,
40-
TypeGuard,
4140
TypeVar,
4241
Union,
4342
)
@@ -767,11 +766,6 @@ def make_db_query(sql):
767766
return decorator
768767

769768

770-
def _is_streamed_span(span: "Any") -> "TypeGuard[StreamedSpan]":
771-
"""Returns True if span is a StreamedSpan (not a NoOpStreamedSpan)."""
772-
return type(span) is StreamedSpan
773-
774-
775769
def _get_current_streamed_span(
776770
scope: "Optional[sentry_sdk.Scope]" = None,
777771
) -> "Optional[StreamedSpan]":

0 commit comments

Comments
 (0)