11import os
22import sys
33import warnings
4- from copy import copy , deepcopy
54from collections import deque
65from contextlib import contextmanager
7- from enum import Enum
6+ from copy import copy , deepcopy
87from datetime import datetime , timezone
8+ from enum import Enum
99from functools import wraps
1010from itertools import chain
11+ from typing import TYPE_CHECKING , cast
1112
1213import sentry_sdk
1314from sentry_sdk ._types import AnnotatedValue
1819 INSTRUMENTER ,
1920 SPANDATA ,
2021)
21- from sentry_sdk .feature_flags import FlagBuffer , DEFAULT_FLAG_CAPACITY
22+ from sentry_sdk .feature_flags import DEFAULT_FLAG_CAPACITY , FlagBuffer
2223from sentry_sdk .profiler .continuous_profiler import (
2324 get_profiler_id ,
2425 try_autostart_continuous_profiler ,
2526 try_profile_lifecycle_trace_start ,
2627)
2728from sentry_sdk .profiler .transaction_profiler import Profile
2829from sentry_sdk .session import Session
29- from sentry_sdk .tracing_utils import (
30- Baggage ,
31- has_tracing_enabled ,
32- has_span_streaming_enabled ,
33- is_ignored_span ,
34- _make_sampling_decision ,
35- PropagationContext ,
36- )
3730from sentry_sdk .traces import (
3831 _DEFAULT_PARENT_SPAN ,
39- StreamedSpan ,
4032 NoOpStreamedSpan ,
41- _is_sampled_streamed_span ,
33+ StreamedSpan ,
34+ _is_streamed_span ,
4235)
4336from sentry_sdk .tracing import (
4437 BAGGAGE_HEADER_NAME ,
4740 Span ,
4841 Transaction ,
4942)
43+ from sentry_sdk .tracing_utils import (
44+ Baggage ,
45+ PropagationContext ,
46+ _make_sampling_decision ,
47+ has_span_streaming_enabled ,
48+ has_tracing_enabled ,
49+ is_ignored_span ,
50+ )
5051from sentry_sdk .utils import (
52+ ContextVar ,
5153 capture_internal_exception ,
5254 capture_internal_exceptions ,
53- ContextVar ,
5455 datetime_from_isoformat ,
5556 disable_capture_event ,
5657 event_from_exception ,
5758 exc_info_from_error ,
5859 format_attribute ,
59- logger ,
6060 has_logs_enabled ,
6161 has_metrics_enabled ,
62+ logger ,
6263)
6364
64- from typing import TYPE_CHECKING , cast
65-
6665if TYPE_CHECKING :
6766 from collections .abc import Mapping
68-
69- from typing import Any
70- from typing import Callable
71- from typing import Deque
72- from typing import Dict
73- from typing import Generator
74- from typing import Iterator
75- from typing import List
76- from typing import Optional
77- from typing import ParamSpec
78- from typing import Tuple
79- from typing import TypeVar
80- from typing import Union
67+ from typing import (
68+ Any ,
69+ Callable ,
70+ Deque ,
71+ Dict ,
72+ Generator ,
73+ Iterator ,
74+ List ,
75+ Optional ,
76+ ParamSpec ,
77+ Tuple ,
78+ TypeVar ,
79+ Union ,
80+ )
8181
8282 from typing_extensions import Unpack
8383
84+ import sentry_sdk
8485 from sentry_sdk ._types import (
8586 Attributes ,
8687 AttributeValue ,
9798 SamplingContext ,
9899 Type ,
99100 )
100-
101101 from sentry_sdk .tracing import TransactionKwargs
102102
103- import sentry_sdk
104-
105103 P = ParamSpec ("P" )
106104 R = TypeVar ("R" )
107105
@@ -590,7 +588,7 @@ def get_traceparent(self, *args: "Any", **kwargs: "Any") -> "Optional[str]":
590588
591589 span_streaming = has_span_streaming_enabled (client .options )
592590 # If we have an active span, return traceparent from there
593- if span_streaming and _is_sampled_streamed_span (self .streamed_span ):
591+ if span_streaming and _is_streamed_span (self .streamed_span ):
594592 return self .streamed_span ._to_traceparent ()
595593 elif not span_streaming and self .span is not None :
596594 return self .span ._to_traceparent ()
@@ -610,7 +608,7 @@ def get_baggage(self, *args: "Any", **kwargs: "Any") -> "Optional[Baggage]":
610608
611609 span_streaming = has_span_streaming_enabled (client .options )
612610 # If we have an active span, return baggage from there
613- if span_streaming and _is_sampled_streamed_span (self .streamed_span ):
611+ if span_streaming and _is_streamed_span (self .streamed_span ):
614612 return self .streamed_span ._to_baggage ()
615613 elif not span_streaming and self .span is not None :
616614 return self .span ._to_baggage ()
@@ -915,7 +913,7 @@ def streamed_span(self, span: "Optional[StreamedSpan]") -> None:
915913
916914 # Also set _transaction and _transaction_info in streaming mode as this
917915 # is used for populating events and linking them to segments
918- if _is_sampled_streamed_span (span ) and span ._is_segment ():
916+ if _is_streamed_span (span ) and span ._is_segment ():
919917 self ._transaction = span .name
920918 if span ._attributes .get ("sentry.span.source" ):
921919 self ._transaction_info ["source" ] = str (
0 commit comments