File tree Expand file tree Collapse file tree 3 files changed +22
-7
lines changed
integrations/opentelemetry Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ def setup_once():
4444 "Use at your own risk."
4545 )
4646
47+ _setup_scope_context_management ()
4748 _setup_sentry_tracing ()
4849 _patch_readable_span ()
4950 # _setup_instrumentors()
@@ -68,12 +69,15 @@ def sentry_patched_readable_span(self):
6869 Span ._readable_span = sentry_patched_readable_span
6970
7071
71- def _setup_sentry_tracing ():
72+ def _setup_scope_context_management ():
7273 # type: () -> None
7374 import opentelemetry .context
7475
7576 opentelemetry .context ._RUNTIME_CONTEXT = SentryContextVarsRuntimeContext ()
7677
78+
79+ def _setup_sentry_tracing ():
80+ # type: () -> None
7781 provider = TracerProvider (sampler = SentrySampler ())
7882 provider .add_span_processor (PotelSentrySpanProcessor ())
7983 trace .set_tracer_provider (provider )
Original file line number Diff line number Diff line change @@ -376,7 +376,7 @@ def get_client(cls):
376376 This checks the current scope, the isolation scope and the global scope for a client.
377377 If no client is available a :py:class:`sentry_sdk.client.NonRecordingClient` is returned.
378378 """
379- current_scope = cls ._get_current_scope ()
379+ current_scope = cls .get_current_scope ()
380380 try :
381381 client = current_scope .client
382382 except AttributeError :
@@ -385,7 +385,7 @@ def get_client(cls):
385385 if client is not None and client .is_active ():
386386 return client
387387
388- isolation_scope = cls ._get_isolation_scope ()
388+ isolation_scope = cls .get_isolation_scope ()
389389 try :
390390 client = isolation_scope .client
391391 except AttributeError :
Original file line number Diff line number Diff line change 1111)
1212from sentry_sdk .client import Client , NonRecordingClient
1313from sentry_sdk .scope import (
14- Scope ,
14+ Scope as BaseScope ,
1515 ScopeType ,
16- use_isolation_scope ,
17- use_scope ,
1816 should_send_default_pii ,
1917)
18+ from sentry_sdk .integrations .opentelemetry .integration import (
19+ _setup_scope_context_management ,
20+ )
21+ from sentry_sdk .integrations .opentelemetry .scope import (
22+ PotelScope as Scope ,
23+ use_scope ,
24+ use_isolation_scope ,
25+ )
2026
2127
2228SLOTS_NOT_COPIED = {"client" }
2329"""__slots__ that are not copied when copying a Scope object."""
2430
2531
32+ @pytest .fixture (autouse = True )
33+ def setup_otel_scope_management ():
34+ _setup_scope_context_management ()
35+
36+
2637def test_copying ():
2738 s1 = Scope ()
2839 s1 .fingerprint = {}
@@ -212,7 +223,7 @@ def test_get_isolation_scope():
212223def test_get_global_scope ():
213224 scope = Scope .get_global_scope ()
214225 assert scope is not None
215- assert scope .__class__ == Scope
226+ assert scope .__class__ == BaseScope
216227 assert scope ._type == ScopeType .GLOBAL
217228
218229
You can’t perform that action at this time.
0 commit comments