From c02da5b1bb290f84f3eac360b914e3dae3608a91 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Wed, 11 Sep 2024 15:07:12 +0200 Subject: [PATCH 1/3] use potelscope --- sentry_sdk/integrations/threading.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/threading.py b/sentry_sdk/integrations/threading.py index c729e208a5..d1fdb7a8e1 100644 --- a/sentry_sdk/integrations/threading.py +++ b/sentry_sdk/integrations/threading.py @@ -4,7 +4,7 @@ import sentry_sdk from sentry_sdk.integrations import Integration -from sentry_sdk.scope import use_isolation_scope, use_scope +from sentry_sdk.integrations.opentelemetry.scope import use_isolation_scope, use_scope from sentry_sdk.utils import ( ensure_integration_enabled, event_from_exception, From 79fc4a3884a530fbf57249cb0ee3a30e4d732da3 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Wed, 11 Sep 2024 15:32:37 +0200 Subject: [PATCH 2/3] Use POTel use_{isolation_}scope --- sentry_sdk/integrations/wsgi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/wsgi.py b/sentry_sdk/integrations/wsgi.py index bfd303235e..4139c9b471 100644 --- a/sentry_sdk/integrations/wsgi.py +++ b/sentry_sdk/integrations/wsgi.py @@ -6,8 +6,8 @@ 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.scope import use_isolation_scope from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_ROUTE from sentry_sdk.utils import ( ContextVar, From 7af488cc048fc4e9bca60d87093beb94dfd32eec Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Wed, 11 Sep 2024 15:59:49 +0200 Subject: [PATCH 3/3] use from top level api --- sentry_sdk/api.py | 4 ++++ sentry_sdk/integrations/threading.py | 5 ++--- sentry_sdk/integrations/wsgi.py | 5 ++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sentry_sdk/api.py b/sentry_sdk/api.py index db0ce275fd..7d06abf660 100644 --- a/sentry_sdk/api.py +++ b/sentry_sdk/api.py @@ -11,6 +11,8 @@ PotelScope as Scope, new_scope, isolation_scope, + use_scope, + use_isolation_scope, ) @@ -77,6 +79,8 @@ "start_transaction", "trace", "monitor", + "use_scope", + "use_isolation_scope", ] diff --git a/sentry_sdk/integrations/threading.py b/sentry_sdk/integrations/threading.py index d1fdb7a8e1..a0444892fb 100644 --- a/sentry_sdk/integrations/threading.py +++ b/sentry_sdk/integrations/threading.py @@ -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, @@ -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() diff --git a/sentry_sdk/integrations/wsgi.py b/sentry_sdk/integrations/wsgi.py index 4139c9b471..15c72ede8a 100644 --- a/sentry_sdk/integrations/wsgi.py +++ b/sentry_sdk/integrations/wsgi.py @@ -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 ( @@ -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: @@ -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: