Skip to content

Commit 88b00f3

Browse files
authored
refactor(logs): apply user attributes to log regardless of send_default_pii (#843)
1 parent 0b251dc commit 88b00f3

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Unreleased
44

5+
### Breaking changes
6+
7+
- refactor(logs): apply user attributes to log regardless of `send_default_pii` (#843) by @lcian
8+
- User attributes should be applied to logs regardless of `send_default_pii`. Therefore, that parameter was removed from `sentry_core::Scope::apply_to_log`.
9+
510
### Features
611

712
- feat(tracing): add support for logs (#840) by @lcian
@@ -16,7 +21,6 @@
1621
});
1722
```
1823

19-
2024
### Fixes
2125

2226
- fix(logs): send environment in `sentry.environment` default attribute (#837) by @lcian

sentry-core/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ impl Client {
411411
/// processing it through `before_send_log`.
412412
#[cfg(feature = "logs")]
413413
fn prepare_log(&self, mut log: Log, scope: &Scope) -> Option<Log> {
414-
scope.apply_to_log(&mut log, self.options.send_default_pii);
414+
scope.apply_to_log(&mut log);
415415

416416
self.set_log_default_attributes(&mut log);
417417

sentry-core/src/scope/real.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl Scope {
351351
/// Applies the contained scoped data to a log, setting the `trace_id` and certain default
352352
/// attributes.
353353
#[cfg(feature = "logs")]
354-
pub fn apply_to_log(&self, log: &mut Log, send_default_pii: bool) {
354+
pub fn apply_to_log(&self, log: &mut Log) {
355355
if let Some(span) = self.span.as_ref() {
356356
log.trace_id = Some(span.get_trace_context().trace_id);
357357
} else {
@@ -373,29 +373,27 @@ impl Scope {
373373
}
374374
}
375375

376-
if send_default_pii {
377-
if let Some(user) = self.user.as_ref() {
378-
if !log.attributes.contains_key("user.id") {
379-
if let Some(id) = user.id.as_ref() {
380-
log.attributes
381-
.insert("user.id".to_owned(), LogAttribute(id.to_owned().into()));
382-
}
376+
if let Some(user) = self.user.as_ref() {
377+
if !log.attributes.contains_key("user.id") {
378+
if let Some(id) = user.id.as_ref() {
379+
log.attributes
380+
.insert("user.id".to_owned(), LogAttribute(id.to_owned().into()));
383381
}
382+
}
384383

385-
if !log.attributes.contains_key("user.name") {
386-
if let Some(name) = user.username.as_ref() {
387-
log.attributes
388-
.insert("user.name".to_owned(), LogAttribute(name.to_owned().into()));
389-
}
384+
if !log.attributes.contains_key("user.name") {
385+
if let Some(name) = user.username.as_ref() {
386+
log.attributes
387+
.insert("user.name".to_owned(), LogAttribute(name.to_owned().into()));
390388
}
389+
}
391390

392-
if !log.attributes.contains_key("user.email") {
393-
if let Some(email) = user.email.as_ref() {
394-
log.attributes.insert(
395-
"user.email".to_owned(),
396-
LogAttribute(email.to_owned().into()),
397-
);
398-
}
391+
if !log.attributes.contains_key("user.email") {
392+
if let Some(email) = user.email.as_ref() {
393+
log.attributes.insert(
394+
"user.email".to_owned(),
395+
LogAttribute(email.to_owned().into()),
396+
);
399397
}
400398
}
401399
}

0 commit comments

Comments
 (0)