Skip to content

Commit

Permalink
Setup scopes before client (#3916)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sl0thentr0py authored Jan 10, 2025
1 parent 869dfea commit ab5d8a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sentry_sdk/_init_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def _init(*args, **kwargs):
This takes the same arguments as the client constructor.
"""
setup_scope_context_management()
client = sentry_sdk.Client(*args, **kwargs)
sentry_sdk.get_global_scope().set_client(client)
setup_scope_context_management()
_check_python_deprecations()


Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ def inner(identifier):
@pytest.fixture
def sentry_init(request):
def inner(*a, **kw):
setup_scope_context_management()
kw.setdefault("transport", TestTransport())
client = sentry_sdk.Client(*a, **kw)
sentry_sdk.get_global_scope().set_client(client)
setup_scope_context_management()

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

0 comments on commit ab5d8a7

Please sign in to comment.