Skip to content

Commit ab5d8a7

Browse files
authored
Setup scopes before client (#3916)
The newly added feature flags add an error processor to `current_scope` in their `setup_once`. This is actually an antipattern and shouldn't be encouraged. Either way, this PR sets up the scopes first since the integrations get setup in the `Client` and require that scope to be correct.
1 parent 869dfea commit ab5d8a7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sentry_sdk/_init_implementation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def _init(*args, **kwargs):
2323
2424
This takes the same arguments as the client constructor.
2525
"""
26+
setup_scope_context_management()
2627
client = sentry_sdk.Client(*args, **kwargs)
2728
sentry_sdk.get_global_scope().set_client(client)
28-
setup_scope_context_management()
2929
_check_python_deprecations()
3030

3131

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ def inner(identifier):
199199
@pytest.fixture
200200
def sentry_init(request):
201201
def inner(*a, **kw):
202+
setup_scope_context_management()
202203
kw.setdefault("transport", TestTransport())
203204
client = sentry_sdk.Client(*a, **kw)
204205
sentry_sdk.get_global_scope().set_client(client)
205-
setup_scope_context_management()
206206

207207
if request.node.get_closest_marker("forked"):
208208
# Do not run isolation if the test is already running in

0 commit comments

Comments
 (0)