Skip to content

Commit

Permalink
feat(eap): Extract user IP (#4144)
Browse files Browse the repository at this point in the history
This starts extracting user IP from the transaction into sentry tags.
  • Loading branch information
Zylphrex authored Oct 16, 2024
1 parent b88fdb7 commit 7fbf4ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- Allowlist the SentryUptimeBot user-agent. ([#4068](https://github.com/getsentry/relay/pull/4068))
- Feature flags of graduated features are now hard-coded in Relay so they can be removed from Sentry. ([#4076](https://github.com/getsentry/relay/pull/4076), [#4080](https://github.com/getsentry/relay/pull/4080))
- Add parallelization in Redis commands. ([#4118](https://github.com/getsentry/relay/pull/4118))
- Extract user ip for spans. ([#4144](https://github.com/getsentry/relay/pull/4144))

## 24.9.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub enum SpanTagKey {
Release,
User,
UserID,
UserIP,
UserUsername,
UserEmail,
Environment,
Expand Down Expand Up @@ -100,6 +101,7 @@ impl SpanTagKey {
SpanTagKey::Release => "release",
SpanTagKey::User => "user",
SpanTagKey::UserID => "user.id",
SpanTagKey::UserIP => "user.ip",
SpanTagKey::UserUsername => "user.username",
SpanTagKey::UserEmail => "user.email",
SpanTagKey::UserCountryCode => "user.geo.country_code",
Expand Down Expand Up @@ -300,6 +302,9 @@ fn extract_shared_tags(event: &Event) -> BTreeMap<SpanTagKey, String> {
if let Some(user_id) = user.id.value() {
tags.insert(SpanTagKey::UserID, user_id.as_str().to_owned());
}
if let Some(user_ip) = user.ip_address.value() {
tags.insert(SpanTagKey::UserIP, user_ip.as_str().to_owned());
}
if let Some(user_username) = user.username.value() {
tags.insert(SpanTagKey::UserUsername, user_username.as_str().to_owned());
}
Expand Down Expand Up @@ -2647,6 +2652,7 @@ LIMIT 1
},
"user": {
"id": "1",
"ip_address": "127.0.0.1",
"email": "admin@sentry.io",
"username": "admin",
"geo": {
Expand Down Expand Up @@ -2680,6 +2686,7 @@ LIMIT 1

assert_eq!(get_value!(span.sentry_tags["user"]!), "id:1");
assert_eq!(get_value!(span.sentry_tags["user.id"]!), "1");
assert_eq!(get_value!(span.sentry_tags["user.ip"]!), "127.0.0.1");
assert_eq!(get_value!(span.sentry_tags["user.username"]!), "admin");
assert_eq!(
get_value!(span.sentry_tags["user.email"]!),
Expand Down

0 comments on commit 7fbf4ca

Please sign in to comment.