File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616 request_body_within_bounds ,
1717)
1818from sentry_sdk .integrations .logging import ignore_logger
19- from sentry_sdk .scope import should_send_default_pii
19+ from sentry_sdk .scope import should_send_default_pii , Scope
2020from sentry_sdk .sessions import track_session
2121from sentry_sdk .traces import (
2222 SOURCE_FOR_STYLE as SEGMENT_SOURCE_FOR_STYLE ,
@@ -139,9 +139,7 @@ async def sentry_app_handle(
139139 span_ctx : "ContextManager[Union[Span, StreamedSpan]]"
140140 if is_span_streaming_enabled :
141141 sentry_sdk .traces .continue_trace (headers )
142- sentry_sdk .get_current_scope ().set_custom_sampling_context (
143- {"aiohttp_request" : request }
144- )
142+ Scope .set_custom_sampling_context ({"aiohttp_request" : request })
145143
146144 header_attributes : "dict[str, Any]" = {}
147145 for header , header_value in _filter_headers (
Original file line number Diff line number Diff line change 4646 capture_internal_exceptions ,
4747 qualname_from_function ,
4848)
49+ from sentry_sdk .scope import Scope
4950
5051from typing import TYPE_CHECKING
5152
@@ -257,9 +258,7 @@ async def _run_app(
257258 ):
258259 sentry_sdk .traces .continue_trace (_get_headers (scope ))
259260
260- sentry_scope .set_custom_sampling_context (
261- {"asgi_scope" : scope }
262- )
261+ Scope .set_custom_sampling_context ({"asgi_scope" : scope })
263262
264263 attributes ["sentry.op" ] = f"{ ty } .server"
265264 segment = sentry_sdk .traces .start_span (
@@ -270,9 +269,7 @@ async def _run_app(
270269 else :
271270 sentry_sdk .traces .new_trace ()
272271
273- sentry_scope .set_custom_sampling_context (
274- {"asgi_scope" : scope }
275- )
272+ Scope .set_custom_sampling_context ({"asgi_scope" : scope })
276273
277274 attributes ["sentry.op" ] = OP .HTTP_SERVER
278275 segment = sentry_sdk .traces .start_span (
Original file line number Diff line number Diff line change 1414)
1515from sentry_sdk .integrations .celery .utils import _now_seconds_since_epoch
1616from sentry_sdk .integrations .logging import ignore_logger
17- from sentry_sdk .scope import should_send_default_pii
17+ from sentry_sdk .scope import should_send_default_pii , Scope
1818from sentry_sdk .traces import StreamedSpan , _get_current_streamed_span
1919from sentry_sdk .tracing import BAGGAGE_HEADER_NAME , Span , TransactionSource
2020from sentry_sdk .tracing_utils import Baggage , has_span_streaming_enabled
@@ -361,7 +361,7 @@ def _inner(*args: "Any", **kwargs: "Any") -> "Any":
361361 headers = args [3 ].get ("headers" ) or {}
362362 if span_streaming :
363363 sentry_sdk .traces .continue_trace (headers )
364- scope .set_custom_sampling_context (custom_sampling_context )
364+ Scope .set_custom_sampling_context (custom_sampling_context )
365365 span = sentry_sdk .traces .start_span (
366366 name = task_name ,
367367 parent_span = None , # make this a segment
Original file line number Diff line number Diff line change 1111 _filter_headers ,
1212 nullcontext ,
1313)
14- from sentry_sdk .scope import should_send_default_pii , use_isolation_scope
14+ from sentry_sdk .scope import should_send_default_pii , use_isolation_scope , Scope
1515from sentry_sdk .sessions import track_session
1616from sentry_sdk .traces import StreamedSpan , SegmentSource
1717from sentry_sdk .tracing import Span , TransactionSource
@@ -132,7 +132,7 @@ def __call__(
132132 sentry_sdk .traces .continue_trace (
133133 dict (_get_headers (environ ))
134134 )
135- scope .set_custom_sampling_context ({"wsgi_environ" : environ })
135+ Scope .set_custom_sampling_context ({"wsgi_environ" : environ })
136136
137137 span_ctx = sentry_sdk .traces .start_span (
138138 name = _DEFAULT_TRANSACTION_NAME ,
Original file line number Diff line number Diff line change @@ -719,10 +719,11 @@ def get_active_propagation_context(self) -> "PropagationContext":
719719 isolation_scope ._propagation_context = PropagationContext ()
720720 return isolation_scope ._propagation_context
721721
722+ @classmethod
722723 def set_custom_sampling_context (
723- self , custom_sampling_context : "dict[str, Any]"
724+ cls , custom_sampling_context : "dict[str, Any]"
724725 ) -> None :
725- self .get_current_scope ().get_active_propagation_context ()._set_custom_sampling_context (
726+ cls .get_current_scope ().get_active_propagation_context ()._set_custom_sampling_context (
726727 custom_sampling_context
727728 )
728729
You can’t perform that action at this time.
0 commit comments