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():
44
44
"Use at your own risk."
45
45
)
46
46
47
+ _setup_scope_context_management ()
47
48
_setup_sentry_tracing ()
48
49
_patch_readable_span ()
49
50
# _setup_instrumentors()
@@ -68,12 +69,15 @@ def sentry_patched_readable_span(self):
68
69
Span ._readable_span = sentry_patched_readable_span
69
70
70
71
71
- def _setup_sentry_tracing ():
72
+ def _setup_scope_context_management ():
72
73
# type: () -> None
73
74
import opentelemetry .context
74
75
75
76
opentelemetry .context ._RUNTIME_CONTEXT = SentryContextVarsRuntimeContext ()
76
77
78
+
79
+ def _setup_sentry_tracing ():
80
+ # type: () -> None
77
81
provider = TracerProvider (sampler = SentrySampler ())
78
82
provider .add_span_processor (PotelSentrySpanProcessor ())
79
83
trace .set_tracer_provider (provider )
Original file line number Diff line number Diff line change @@ -376,7 +376,7 @@ def get_client(cls):
376
376
This checks the current scope, the isolation scope and the global scope for a client.
377
377
If no client is available a :py:class:`sentry_sdk.client.NonRecordingClient` is returned.
378
378
"""
379
- current_scope = cls ._get_current_scope ()
379
+ current_scope = cls .get_current_scope ()
380
380
try :
381
381
client = current_scope .client
382
382
except AttributeError :
@@ -385,7 +385,7 @@ def get_client(cls):
385
385
if client is not None and client .is_active ():
386
386
return client
387
387
388
- isolation_scope = cls ._get_isolation_scope ()
388
+ isolation_scope = cls .get_isolation_scope ()
389
389
try :
390
390
client = isolation_scope .client
391
391
except AttributeError :
Original file line number Diff line number Diff line change 11
11
)
12
12
from sentry_sdk .client import Client , NonRecordingClient
13
13
from sentry_sdk .scope import (
14
- Scope ,
14
+ Scope as BaseScope ,
15
15
ScopeType ,
16
- use_isolation_scope ,
17
- use_scope ,
18
16
should_send_default_pii ,
19
17
)
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
+ )
20
26
21
27
22
28
SLOTS_NOT_COPIED = {"client" }
23
29
"""__slots__ that are not copied when copying a Scope object."""
24
30
25
31
32
+ @pytest .fixture (autouse = True )
33
+ def setup_otel_scope_management ():
34
+ _setup_scope_context_management ()
35
+
36
+
26
37
def test_copying ():
27
38
s1 = Scope ()
28
39
s1 .fingerprint = {}
@@ -212,7 +223,7 @@ def test_get_isolation_scope():
212
223
def test_get_global_scope ():
213
224
scope = Scope .get_global_scope ()
214
225
assert scope is not None
215
- assert scope .__class__ == Scope
226
+ assert scope .__class__ == BaseScope
216
227
assert scope ._type == ScopeType .GLOBAL
217
228
218
229
You can’t perform that action at this time.
0 commit comments