Skip to content

Commit

Permalink
fix(spans): check sdk platform for user.geo.subregion tag (#4023)
Browse files Browse the repository at this point in the history
This is an extension of this PR
#4013

I assumed that Backend SDK transactions would not have a browser
context, so i used that as a means to check if the project is a frontend
project. Turns out, python SDKs still set browser context on the
transaction (I guess this is the browser the user made the request
from?). So to fix this, we can just check the platform directly as
frontend is typically/always javascript.

---------

Co-authored-by: Joris Bayer <joris.bayer@sentry.io>
  • Loading branch information
DominikB2014 and jjbayer authored Sep 11, 2024
1 parent 8c3c3c2 commit b82aa67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- Remove the OTEL spans endpoint in favor of Envelopes. ([#3973](https://github.com/getsentry/relay/pull/3973))
- Remove the `generate-schema` tool. Relay no longer exposes JSON schema for the event protocol. Consult the Rust type documentation of the `relay-event-schema` crate instead. ([#3974](https://github.com/getsentry/relay/pull/3974))
- Allow creation of `SqliteEnvelopeBuffer` from config, and load existing stacks from db on startup. ([#3967](https://github.com/getsentry/relay/pull/3967))
- Only tag `user.geo.subregion` on frontend and mobile projects. ([#4013](https://github.com/getsentry/relay/pull/4013))
- Only tag `user.geo.subregion` on frontend and mobile projects. ([#4013](https://github.com/getsentry/relay/pull/4013), [#4023](https://github.com/getsentry/relay/pull/4023))

## 24.8.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,9 @@ fn extract_shared_tags(event: &Event) -> BTreeMap<SpanTagKey, String> {
}

// We only want this on frontend or mobile modules.
let should_extract_geo =
event.context::<BrowserContext>().is_some() || MOBILE_SDKS.contains(&event.sdk_name());
let should_extract_geo = (event.context::<BrowserContext>().is_some()
&& event.platform.as_str() == Some("javascript"))
|| MOBILE_SDKS.contains(&event.sdk_name());

if should_extract_geo {
if let Some(country_code) = user.geo.value().and_then(|geo| geo.country_code.value()) {
Expand Down Expand Up @@ -2745,6 +2746,9 @@ LIMIT 1
"trace": {
"trace_id": "ff62a8b040f340bda5d830223def1d81",
"span_id": "bd429c44b67a3eb4"
},
"browser": {
"name": "Chrome"
}
},
"user": {
Expand Down

0 comments on commit b82aa67

Please sign in to comment.