Skip to content

Commit a4bc9de

Browse files
authored
Use POTel use_scope, use_isolation_scope (#3522)
* use potelscope * Use POTel use_{isolation_}scope * use from top level api
1 parent b27a43f commit a4bc9de

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

sentry_sdk/api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
PotelScope as Scope,
1212
new_scope,
1313
isolation_scope,
14+
use_scope,
15+
use_isolation_scope,
1416
)
1517

1618

@@ -77,6 +79,8 @@
7779
"start_transaction",
7880
"trace",
7981
"monitor",
82+
"use_scope",
83+
"use_isolation_scope",
8084
]
8185

8286

sentry_sdk/integrations/threading.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import sentry_sdk
66
from sentry_sdk.integrations import Integration
7-
from sentry_sdk.scope import use_isolation_scope, use_scope
87
from sentry_sdk.utils import (
98
ensure_integration_enabled,
109
event_from_exception,
@@ -95,8 +94,8 @@ def _run_old_run_func():
9594
reraise(*_capture_exception())
9695

9796
if isolation_scope_to_use is not None and current_scope_to_use is not None:
98-
with use_isolation_scope(isolation_scope_to_use):
99-
with use_scope(current_scope_to_use):
97+
with sentry_sdk.use_isolation_scope(isolation_scope_to_use):
98+
with sentry_sdk.use_scope(current_scope_to_use):
10099
return _run_old_run_func()
101100
else:
102101
return _run_old_run_func()

sentry_sdk/integrations/wsgi.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from sentry_sdk.scope import should_send_default_pii
88
from sentry_sdk.integrations._wsgi_common import _filter_headers
99
from sentry_sdk.sessions import track_session
10-
from sentry_sdk.scope import use_isolation_scope
1110
from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_ROUTE
1211
from sentry_sdk.utils import (
1312
ContextVar,
@@ -219,7 +218,7 @@ def __iter__(self):
219218
iterator = iter(self._response)
220219

221220
while True:
222-
with use_isolation_scope(self._scope):
221+
with sentry_sdk.use_isolation_scope(self._scope):
223222
try:
224223
chunk = next(iterator)
225224
except StopIteration:
@@ -231,7 +230,7 @@ def __iter__(self):
231230

232231
def close(self):
233232
# type: () -> None
234-
with use_isolation_scope(self._scope):
233+
with sentry_sdk.use_isolation_scope(self._scope):
235234
try:
236235
self._response.close() # type: ignore
237236
except AttributeError:

0 commit comments

Comments
 (0)