-
Notifications
You must be signed in to change notification settings - Fork 549
feat(logs): Add user attributes to logs #4423
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
base: master
Are you sure you want to change the base?
Conversation
❌ 47 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
@@ -927,6 +927,20 @@ def _capture_experimental_log(self, current_scope, log): | |||
elif propagation_context is not None: | |||
log["trace_id"] = propagation_context.trace_id | |||
|
|||
if self.should_send_default_pii() and isolation_scope._user is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we also check the global and current scope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be necessary. User should always only be set on the isolation scope:
sentry-python/sentry_sdk/api.py
Lines 332 to 334 in 747f0f3
def set_user(value): | |
# type: (Optional[Dict[str, Any]]) -> None | |
return get_isolation_scope().set_user(value) |
I checked the (few) places we manually call set_user
on a scope, these also use the isolation scope only.
747f0f3
to
a903eb6
Compare
a903eb6
to
285abb0
Compare
Example log with user attributes: https://sentry-sdks.sentry.io/explore/logs/trace/362b3309f7f9471eb504af407bf51932/?logsSortBys=-timestamp&project=4505239425777664&source=logs&tab=logs×tamp=1748448946
Closes #4422