diff --git a/CHANGELOG.md b/CHANGELOG.md index 1723363f9b..b0292d3c5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - Make the tcp listen backlog configurable and raise the default to 1024. ([#3899](https://github.com/getsentry/relay/pull/3899)) - Extract `user.geo.country_code` into span indexed. ([#3911](https://github.com/getsentry/relay/pull/3911)) - Add `span.system` tag to span metrics ([#3913](https://github.com/getsentry/relay/pull/3913)) +- Extract client sdk from transaction into profiles. ([#3915](https://github.com/getsentry/relay/pull/3915)) ## 24.7.1 diff --git a/relay-profiling/src/android.rs b/relay-profiling/src/android.rs index d6c8e80af1..b1c54b6386 100644 --- a/relay-profiling/src/android.rs +++ b/relay-profiling/src/android.rs @@ -91,6 +91,15 @@ pub struct ProfileMetadata { #[serde(skip_serializing_if = "Option::is_none")] debug_meta: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + client_sdk: Option, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct ClientSdk { + name: String, + version: String, } #[derive(Debug, Serialize, Deserialize, Clone)] @@ -237,6 +246,16 @@ pub fn parse_android_profile( } } + profile.metadata.client_sdk = match ( + transaction_metadata.get("client_sdk.name"), + transaction_metadata.get("client_sdk.version"), + ) { + (Some(name), Some(version)) => Some(ClientSdk { + name: name.to_owned(), + version: version.to_owned(), + }), + _ => None, + }; profile.metadata.transaction_metadata = transaction_metadata; profile.metadata.transaction_tags = transaction_tags; diff --git a/relay-profiling/src/extract_from_transaction.rs b/relay-profiling/src/extract_from_transaction.rs index cc77ef2942..edda4e1337 100644 --- a/relay-profiling/src/extract_from_transaction.rs +++ b/relay-profiling/src/extract_from_transaction.rs @@ -62,6 +62,15 @@ pub fn extract_transaction_metadata(event: &Event) -> BTreeMap { } } + if let Some(client_sdk) = event.client_sdk.value() { + if let Some(sdk_name) = client_sdk.name.value() { + tags.insert("client_sdk.name".to_owned(), sdk_name.to_owned()); + } + if let Some(sdk_version) = client_sdk.version.value() { + tags.insert("client_sdk.version".to_owned(), sdk_version.to_owned()); + } + } + tags } @@ -125,14 +134,20 @@ mod tests { }, "timestamp": "2011-05-02T17:41:36Z", "start_timestamp": "2011-05-02T17:40:36Z", + "sdk": { + "name": "sentry.python", + "version": "2.10.7", + }, }) .into(), ); let metadata = extract_transaction_metadata(&event.0.unwrap()); - insta::assert_debug_snapshot!(metadata, @r#" + insta::assert_debug_snapshot!(metadata, @r###" { "app.identifier": "io.sentry.myexample", + "client_sdk.name": "sentry.python", + "client_sdk.version": "2.10.7", "dist": "mydist", "environment": "myenvironment", "http.method": "GET", @@ -143,6 +158,6 @@ mod tests { "transaction.start": "2011-05-02T17:40:36.000000000+00:00", "transaction.status": "ok", } - "#); + "###); } } diff --git a/relay-profiling/src/sample/v1.rs b/relay-profiling/src/sample/v1.rs index 222c0a82a8..e3f32ff20d 100644 --- a/relay-profiling/src/sample/v1.rs +++ b/relay-profiling/src/sample/v1.rs @@ -255,6 +255,15 @@ pub struct ProfileMetadata { #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] transaction_tags: BTreeMap, + + #[serde(skip_serializing_if = "Option::is_none")] + pub client_sdk: Option, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct ClientSdk { + name: String, + version: String, } #[derive(Debug, Serialize, Deserialize, Clone)] @@ -354,6 +363,16 @@ pub fn parse_sample_profile( } } + profile.metadata.client_sdk = match ( + transaction_metadata.get("client_sdk.name"), + transaction_metadata.get("client_sdk.version"), + ) { + (Some(name), Some(version)) => Some(ClientSdk { + name: name.to_owned(), + version: version.to_owned(), + }), + _ => None, + }; profile.metadata.transaction_metadata = transaction_metadata; profile.metadata.transaction_tags = transaction_tags; @@ -410,6 +429,7 @@ mod tests { dist: "9999".to_string(), transaction_metadata: BTreeMap::new(), transaction_tags: BTreeMap::new(), + client_sdk: None, }, profile: SampleProfile { queue_metadata: Some(HashMap::new()),