Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): configure_scope deprecation warning #3351

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sentry_sdk/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import inspect
import warnings
from contextlib import contextmanager

from sentry_sdk import tracing_utils, Client
Expand Down Expand Up @@ -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()

Expand Down
7 changes: 7 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
is_initialized,
start_transaction,
set_tags,
configure_scope,
)

from sentry_sdk.client import Client, NonRecordingClient
Expand Down Expand Up @@ -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():
...
4 changes: 3 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading