Skip to content

Commit

Permalink
Also merge 'self' into merged data that is sent to Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Feb 20, 2024
1 parent e556a17 commit ab0b06b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,9 @@ def get_global_scope(cls):

return _global_scope

@classmethod
def _merge_scopes(cls, additional_scope=None, additional_scope_kwargs=None):
def _merge_scopes(self, additional_scope=None, additional_scope_kwargs=None):
# type: (Optional[Scope], Optional[Dict[str, Any]]) -> Scope
"""
.. versionadded:: 2.0.0
Merges global, isolation and current scope into a new scope and
adds the given additional scope or additional scope kwargs to it.
"""
Expand All @@ -302,6 +299,8 @@ def _merge_scopes(cls, additional_scope=None, additional_scope_kwargs=None):
if current_scope is not None:
final_scope.update_from_scope(current_scope)

final_scope.update_from_scope(self)

if additional_scope is not None:
if callable(additional_scope):
additional_scope(final_scope)

Check warning on line 306 in sentry_sdk/scope.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/scope.py#L306

Added line #L306 was not covered by tests
Expand Down Expand Up @@ -1042,7 +1041,7 @@ def capture_event(self, event, hint=None, scope=None, **scope_kwargs):
:returns: An `event_id` if the SDK decided to send the event (see :py:meth:`sentry_sdk.client._Client.capture_event`).
"""
scope = Scope._merge_scopes(scope, scope_kwargs)
scope = self._merge_scopes(scope, scope_kwargs)

return Scope.get_client().capture_event(event=event, hint=hint, scope=scope)

Expand Down

0 comments on commit ab0b06b

Please sign in to comment.