diff --git a/sentry_sdk/api.py b/sentry_sdk/api.py index 41c4814146..d28dbd92d0 100644 --- a/sentry_sdk/api.py +++ b/sentry_sdk/api.py @@ -1,4 +1,5 @@ import inspect +import warnings from contextlib import contextmanager from sentry_sdk import tracing_utils, Client @@ -185,6 +186,14 @@ def configure_scope( # noqa: F811 :returns: If no callback is provided, returns a context manager that returns the scope. """ + warnings.warn( + "sentry_sdk.configure_scope is deprecated and will be removed in the next major version. " + "Please consult our migration guide to learn how to migrate to the new API: " + "https://docs.sentry.io/platforms/python/migration/1.x-to-2.x#scope-configuring", + DeprecationWarning, + stacklevel=2, + ) + scope = Scope.get_isolation_scope() scope.generate_propagation_context() diff --git a/tests/test_api.py b/tests/test_api.py index a6c44260d7..1f2a1b783f 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -11,6 +11,7 @@ is_initialized, start_transaction, set_tags, + configure_scope, ) from sentry_sdk.client import Client, NonRecordingClient @@ -179,3 +180,9 @@ def test_set_tags(sentry_init, capture_events): "tag2": "updated", "tag3": "new", }, "Updating tags with empty dict changed tags" + + +def test_configure_scope_deprecation(): + with pytest.warns(DeprecationWarning): + with configure_scope(): + ... diff --git a/tests/test_client.py b/tests/test_client.py index 4abf016889..15a140d377 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -570,7 +570,9 @@ def capture_envelope(self, envelope): assert output.count(b"HI") == num_messages -def test_configure_scope_available(sentry_init, request, monkeypatch): +def test_configure_scope_available( + sentry_init, request, monkeypatch, suppress_deprecation_warnings +): """ Test that scope is configured if client is configured