Skip to content

Commit

Permalink
use from top level api
Browse files Browse the repository at this point in the history
  • Loading branch information
sentrivana committed Sep 11, 2024
1 parent 79fc4a3 commit 7af488c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 4 additions & 0 deletions sentry_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
PotelScope as Scope,
new_scope,
isolation_scope,
use_scope,
use_isolation_scope,
)


Expand Down Expand Up @@ -77,6 +79,8 @@
"start_transaction",
"trace",
"monitor",
"use_scope",
"use_isolation_scope",
]


Expand Down
5 changes: 2 additions & 3 deletions sentry_sdk/integrations/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import sentry_sdk
from sentry_sdk.integrations import Integration
from sentry_sdk.integrations.opentelemetry.scope import use_isolation_scope, use_scope
from sentry_sdk.utils import (
ensure_integration_enabled,
event_from_exception,
Expand Down Expand Up @@ -95,8 +94,8 @@ def _run_old_run_func():
reraise(*_capture_exception())

if isolation_scope_to_use is not None and current_scope_to_use is not None:
with use_isolation_scope(isolation_scope_to_use):
with use_scope(current_scope_to_use):
with sentry_sdk.use_isolation_scope(isolation_scope_to_use):
with sentry_sdk.use_scope(current_scope_to_use):
return _run_old_run_func()
else:
return _run_old_run_func()
Expand Down
5 changes: 2 additions & 3 deletions sentry_sdk/integrations/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from sentry_sdk.consts import OP
from sentry_sdk.scope import should_send_default_pii
from sentry_sdk.integrations._wsgi_common import _filter_headers
from sentry_sdk.integrations.opentelemetry.scope import use_isolation_scope
from sentry_sdk.sessions import track_session
from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_ROUTE
from sentry_sdk.utils import (
Expand Down Expand Up @@ -219,7 +218,7 @@ def __iter__(self):
iterator = iter(self._response)

while True:
with use_isolation_scope(self._scope):
with sentry_sdk.use_isolation_scope(self._scope):
try:
chunk = next(iterator)
except StopIteration:
Expand All @@ -231,7 +230,7 @@ def __iter__(self):

def close(self):
# type: () -> None
with use_isolation_scope(self._scope):
with sentry_sdk.use_isolation_scope(self._scope):
try:
self._response.close() # type: ignore
except AttributeError:
Expand Down

0 comments on commit 7af488c

Please sign in to comment.