-
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
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #4423 +/- ##
==========================================
- Coverage 80.67% 80.64% -0.03%
==========================================
Files 142 142
Lines 15982 15986 +4
Branches 2729 2732 +3
==========================================
- Hits 12893 12892 -1
- Misses 2232 2238 +6
+ Partials 857 856 -1
|
@@ -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.
a903eb6
to
285abb0
Compare
285abb0
to
076e4d1
Compare
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.
looks good.
We are always just using the current scope anyway; it is less confusing if we eliminate the parameter Stacked on: - #4423
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