From 4580325014cf334d0222653e49fc36d0b5af1088 Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Thu, 8 Aug 2024 17:13:00 -0400 Subject: [PATCH 1/4] feat(profiling): Extract client sdk for profiles Similar to #3882, but for the existing formats. Extract the sdk info from the transaction event. --- relay-profiling/src/android.rs | 34 ++++++++---- relay-profiling/src/client_sdk.rs | 7 +++ .../src/extract_from_transaction.rs | 54 +++++++++++++++++++ relay-profiling/src/lib.rs | 24 ++++++--- relay-profiling/src/sample/v1.rs | 15 ++++-- relay-profiling/src/sample/v2.rs | 7 +-- 6 files changed, 116 insertions(+), 25 deletions(-) create mode 100644 relay-profiling/src/client_sdk.rs diff --git a/relay-profiling/src/android.rs b/relay-profiling/src/android.rs index d6c8e80af1..1326c67ead 100644 --- a/relay-profiling/src/android.rs +++ b/relay-profiling/src/android.rs @@ -14,6 +14,7 @@ use data_encoding::BASE64_NOPAD; use relay_event_schema::protocol::{EventId, SpanId}; use serde::{Deserialize, Serialize}; +use crate::client_sdk::ClientSdk; use crate::measurements::Measurement; use crate::native_debug_image::NativeDebugImage; use crate::sample::v1::SampleProfile; @@ -91,6 +92,9 @@ 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)] @@ -203,11 +207,14 @@ fn parse_profile(payload: &[u8]) -> Result pub fn parse_android_profile( payload: &[u8], + client_sdk: Option, transaction_metadata: BTreeMap, transaction_tags: BTreeMap, ) -> Result, ProfileError> { let mut profile = parse_profile(payload)?; + profile.metadata.client_sdk = client_sdk; + if let Some(transaction_name) = transaction_metadata.get("transaction") { transaction_name.clone_into(&mut profile.metadata.transaction_name); @@ -253,9 +260,13 @@ mod tests { let profile = parse_profile(payload); assert!(profile.is_ok()); let data = serde_json::to_vec(&profile.unwrap()); - assert!( - parse_android_profile(&(data.unwrap())[..], BTreeMap::new(), BTreeMap::new()).is_ok() - ); + assert!(parse_android_profile( + &(data.unwrap())[..], + None, + BTreeMap::new(), + BTreeMap::new() + ) + .is_ok()); } #[test] @@ -264,22 +275,26 @@ mod tests { let profile = parse_profile(payload); assert!(profile.is_ok()); let data = serde_json::to_vec(&profile.unwrap()); - assert!( - parse_android_profile(&(data.unwrap())[..], BTreeMap::new(), BTreeMap::new()).is_ok() - ); + assert!(parse_android_profile( + &(data.unwrap())[..], + None, + BTreeMap::new(), + BTreeMap::new() + ) + .is_ok()); } #[test] fn test_no_transaction() { let payload = include_bytes!("../tests/fixtures/android/no_transaction.json"); - let data = parse_android_profile(payload, BTreeMap::new(), BTreeMap::new()); + let data = parse_android_profile(payload, None, BTreeMap::new(), BTreeMap::new()); assert!(data.is_err()); } #[test] fn test_remove_invalid_events() { let payload = include_bytes!("../tests/fixtures/android/remove_invalid_events.json"); - let data = parse_android_profile(payload, BTreeMap::new(), BTreeMap::new()); + let data = parse_android_profile(payload, None, BTreeMap::new(), BTreeMap::new()); assert!(data.is_err()); } @@ -315,7 +330,8 @@ mod tests { ]); let payload = include_bytes!("../tests/fixtures/android/valid.json"); - let profile_json = parse_android_profile(payload, transaction_metadata, BTreeMap::new()); + let profile_json = + parse_android_profile(payload, None, transaction_metadata, BTreeMap::new()); assert!(profile_json.is_ok()); let payload = profile_json.unwrap(); diff --git a/relay-profiling/src/client_sdk.rs b/relay-profiling/src/client_sdk.rs new file mode 100644 index 0000000000..f15d33e827 --- /dev/null +++ b/relay-profiling/src/client_sdk.rs @@ -0,0 +1,7 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +pub struct ClientSdk { + pub name: String, + pub version: String, +} diff --git a/relay-profiling/src/extract_from_transaction.rs b/relay-profiling/src/extract_from_transaction.rs index cc77ef2942..ce26d61f0d 100644 --- a/relay-profiling/src/extract_from_transaction.rs +++ b/relay-profiling/src/extract_from_transaction.rs @@ -4,6 +4,8 @@ use chrono::SecondsFormat; use relay_event_schema::protocol::{AppContext, AsPair, Event, SpanStatus, TraceContext}; +use crate::client_sdk::ClientSdk; + pub fn extract_transaction_metadata(event: &Event) -> BTreeMap { let mut tags = BTreeMap::new(); @@ -98,6 +100,19 @@ fn extract_http_method(transaction: &Event) -> Option { Some(method.clone()) } +pub fn extract_sdk_metadata(transaction: &Event) -> Option { + match transaction.client_sdk.value() { + Some(client_sdk) => match (client_sdk.name.value(), client_sdk.version.value()) { + (Some(name), Some(version)) => Some(ClientSdk { + name: name.to_owned(), + version: version.to_owned(), + }), + _ => None, + }, + None => None, + } +} + #[cfg(test)] mod tests { use super::*; @@ -145,4 +160,43 @@ mod tests { } "#); } + + #[test] + fn test_extract_sdk_metadata() { + let event = Event::from_value( + serde_json::json!({ + "release": "myrelease", + "dist": "mydist", + "environment": "myenvironment", + "transaction": "mytransaction", + "contexts": { + "app": { + "app_identifier": "io.sentry.myexample", + }, + "trace": { + "status": "ok", + "op": "myop", + }, + }, + "request": { + "method": "GET", + }, + "timestamp": "2011-05-02T17:41:36Z", + "start_timestamp": "2011-05-02T17:40:36Z", + "sdk": { + "name": "sentry.python", + "version": "2.10.7", + }, + }) + .into(), + ); + let sdk = extract_sdk_metadata(&event.0.unwrap()); + assert_eq!( + sdk, + Some(ClientSdk { + name: "sentry.python".to_string(), + version: "2.10.7".to_string(), + }) + ); + } } diff --git a/relay-profiling/src/lib.rs b/relay-profiling/src/lib.rs index ce072a5fed..66c1b1487d 100644 --- a/relay-profiling/src/lib.rs +++ b/relay-profiling/src/lib.rs @@ -47,12 +47,15 @@ use relay_event_schema::protocol::{Event, EventId}; use serde::Deserialize; use serde_json::Deserializer; -use crate::extract_from_transaction::{extract_transaction_metadata, extract_transaction_tags}; +use crate::extract_from_transaction::{ + extract_sdk_metadata, extract_transaction_metadata, extract_transaction_tags, +}; pub use crate::error::ProfileError; pub use crate::outcomes::discard_reason; mod android; +mod client_sdk; mod error; mod extract_from_transaction; mod measurements; @@ -154,16 +157,23 @@ pub fn expand_profile(payload: &[u8], event: &Event) -> Result<(ProfileId, Vec { - sample::v1::parse_sample_profile(payload, transaction_metadata, transaction_tags) - } + sample::Version::V1 => sample::v1::parse_sample_profile( + payload, + client_sdk, + transaction_metadata, + transaction_tags, + ), _ => match profile.platform.as_str() { - "android" => { - android::parse_android_profile(payload, transaction_metadata, transaction_tags) - } + "android" => android::parse_android_profile( + payload, + client_sdk, + transaction_metadata, + transaction_tags, + ), _ => return Err(ProfileError::PlatformNotSupported), }, }; diff --git a/relay-profiling/src/sample/v1.rs b/relay-profiling/src/sample/v1.rs index 222c0a82a8..19ccacadfb 100644 --- a/relay-profiling/src/sample/v1.rs +++ b/relay-profiling/src/sample/v1.rs @@ -12,6 +12,7 @@ use itertools::Itertools; use relay_event_schema::protocol::{EventId, SpanId}; use serde::{Deserialize, Serialize}; +use crate::client_sdk::ClientSdk; use crate::error::ProfileError; use crate::measurements::Measurement; use crate::sample::{DebugMeta, Frame, ThreadMetadata, Version}; @@ -255,6 +256,9 @@ 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)] @@ -322,11 +326,14 @@ fn parse_profile(payload: &[u8]) -> Result { pub fn parse_sample_profile( payload: &[u8], + client_sdk: Option, transaction_metadata: BTreeMap, transaction_tags: BTreeMap, ) -> Result, ProfileError> { let mut profile = parse_profile(payload)?; + profile.metadata.client_sdk = client_sdk; + if let Some(transaction_name) = transaction_metadata.get("transaction") { if let Some(ref mut transaction) = profile.metadata.transaction { transaction_name.clone_into(&mut transaction.name) @@ -377,7 +384,7 @@ mod tests { #[test] fn test_expand() { let payload = include_bytes!("../../tests/fixtures/sample/v1/valid.json"); - let profile = parse_sample_profile(payload, BTreeMap::new(), BTreeMap::new()); + let profile = parse_sample_profile(payload, None, BTreeMap::new(), BTreeMap::new()); assert!(profile.is_ok()); } @@ -410,6 +417,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()), @@ -593,7 +601,7 @@ mod tests { ]); let payload = serde_json::to_vec(&profile).unwrap(); - let data = parse_sample_profile(&payload[..], BTreeMap::new(), BTreeMap::new()); + let data = parse_sample_profile(&payload[..], None, BTreeMap::new(), BTreeMap::new()); assert!(data.is_err()); } @@ -873,7 +881,8 @@ mod tests { )]); let payload = include_bytes!("../../tests/fixtures/sample/v1/valid.json"); - let profile_json = parse_sample_profile(payload, transaction_metadata, BTreeMap::new()); + let profile_json = + parse_sample_profile(payload, None, transaction_metadata, BTreeMap::new()); assert!(profile_json.is_ok()); let payload = profile_json.unwrap(); diff --git a/relay-profiling/src/sample/v2.rs b/relay-profiling/src/sample/v2.rs index d5b5832c59..8573b6adad 100644 --- a/relay-profiling/src/sample/v2.rs +++ b/relay-profiling/src/sample/v2.rs @@ -16,6 +16,7 @@ use serde::{Deserialize, Serialize}; use relay_event_schema::protocol::EventId; use relay_metrics::FiniteF64; +use crate::client_sdk::ClientSdk; use crate::error::ProfileError; use crate::measurements::Measurement; use crate::sample::{DebugMeta, Frame, ThreadMetadata, Version}; @@ -42,12 +43,6 @@ pub struct ProfileMetadata { pub version: Version, } -#[derive(Debug, Serialize, Deserialize)] -pub struct ClientSdk { - name: String, - version: String, -} - #[derive(Debug, Serialize, Deserialize)] pub struct Sample { /// Unix timestamp in seconds with millisecond precision when the sample From e3d3e7c1852c5f92cbad658a33387608a7a4587b Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Fri, 9 Aug 2024 17:13:26 -0400 Subject: [PATCH 2/4] use extract metadata instead --- relay-profiling/src/android.rs | 40 +++++----- .../src/extract_from_transaction.rs | 73 +++++-------------- relay-profiling/src/lib.rs | 23 ++---- relay-profiling/src/sample/v1.rs | 20 +++-- 4 files changed, 56 insertions(+), 100 deletions(-) diff --git a/relay-profiling/src/android.rs b/relay-profiling/src/android.rs index 1326c67ead..c66940946a 100644 --- a/relay-profiling/src/android.rs +++ b/relay-profiling/src/android.rs @@ -207,14 +207,11 @@ fn parse_profile(payload: &[u8]) -> Result pub fn parse_android_profile( payload: &[u8], - client_sdk: Option, transaction_metadata: BTreeMap, transaction_tags: BTreeMap, ) -> Result, ProfileError> { let mut profile = parse_profile(payload)?; - profile.metadata.client_sdk = client_sdk; - if let Some(transaction_name) = transaction_metadata.get("transaction") { transaction_name.clone_into(&mut profile.metadata.transaction_name); @@ -244,6 +241,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; @@ -260,13 +267,9 @@ mod tests { let profile = parse_profile(payload); assert!(profile.is_ok()); let data = serde_json::to_vec(&profile.unwrap()); - assert!(parse_android_profile( - &(data.unwrap())[..], - None, - BTreeMap::new(), - BTreeMap::new() - ) - .is_ok()); + assert!( + parse_android_profile(&(data.unwrap())[..], BTreeMap::new(), BTreeMap::new()).is_ok() + ); } #[test] @@ -275,26 +278,22 @@ mod tests { let profile = parse_profile(payload); assert!(profile.is_ok()); let data = serde_json::to_vec(&profile.unwrap()); - assert!(parse_android_profile( - &(data.unwrap())[..], - None, - BTreeMap::new(), - BTreeMap::new() - ) - .is_ok()); + assert!( + parse_android_profile(&(data.unwrap())[..], BTreeMap::new(), BTreeMap::new()).is_ok() + ); } #[test] fn test_no_transaction() { let payload = include_bytes!("../tests/fixtures/android/no_transaction.json"); - let data = parse_android_profile(payload, None, BTreeMap::new(), BTreeMap::new()); + let data = parse_android_profile(payload, BTreeMap::new(), BTreeMap::new()); assert!(data.is_err()); } #[test] fn test_remove_invalid_events() { let payload = include_bytes!("../tests/fixtures/android/remove_invalid_events.json"); - let data = parse_android_profile(payload, None, BTreeMap::new(), BTreeMap::new()); + let data = parse_android_profile(payload, BTreeMap::new(), BTreeMap::new()); assert!(data.is_err()); } @@ -330,8 +329,7 @@ mod tests { ]); let payload = include_bytes!("../tests/fixtures/android/valid.json"); - let profile_json = - parse_android_profile(payload, None, transaction_metadata, BTreeMap::new()); + let profile_json = parse_android_profile(payload, transaction_metadata, BTreeMap::new()); assert!(profile_json.is_ok()); let payload = profile_json.unwrap(); diff --git a/relay-profiling/src/extract_from_transaction.rs b/relay-profiling/src/extract_from_transaction.rs index ce26d61f0d..edda4e1337 100644 --- a/relay-profiling/src/extract_from_transaction.rs +++ b/relay-profiling/src/extract_from_transaction.rs @@ -4,8 +4,6 @@ use chrono::SecondsFormat; use relay_event_schema::protocol::{AppContext, AsPair, Event, SpanStatus, TraceContext}; -use crate::client_sdk::ClientSdk; - pub fn extract_transaction_metadata(event: &Event) -> BTreeMap { let mut tags = BTreeMap::new(); @@ -64,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 } @@ -100,19 +107,6 @@ fn extract_http_method(transaction: &Event) -> Option { Some(method.clone()) } -pub fn extract_sdk_metadata(transaction: &Event) -> Option { - match transaction.client_sdk.value() { - Some(client_sdk) => match (client_sdk.name.value(), client_sdk.version.value()) { - (Some(name), Some(version)) => Some(ClientSdk { - name: name.to_owned(), - version: version.to_owned(), - }), - _ => None, - }, - None => None, - } -} - #[cfg(test)] mod tests { use super::*; @@ -140,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", @@ -158,45 +158,6 @@ mod tests { "transaction.start": "2011-05-02T17:40:36.000000000+00:00", "transaction.status": "ok", } - "#); - } - - #[test] - fn test_extract_sdk_metadata() { - let event = Event::from_value( - serde_json::json!({ - "release": "myrelease", - "dist": "mydist", - "environment": "myenvironment", - "transaction": "mytransaction", - "contexts": { - "app": { - "app_identifier": "io.sentry.myexample", - }, - "trace": { - "status": "ok", - "op": "myop", - }, - }, - "request": { - "method": "GET", - }, - "timestamp": "2011-05-02T17:41:36Z", - "start_timestamp": "2011-05-02T17:40:36Z", - "sdk": { - "name": "sentry.python", - "version": "2.10.7", - }, - }) - .into(), - ); - let sdk = extract_sdk_metadata(&event.0.unwrap()); - assert_eq!( - sdk, - Some(ClientSdk { - name: "sentry.python".to_string(), - version: "2.10.7".to_string(), - }) - ); + "###); } } diff --git a/relay-profiling/src/lib.rs b/relay-profiling/src/lib.rs index 66c1b1487d..8a895a227b 100644 --- a/relay-profiling/src/lib.rs +++ b/relay-profiling/src/lib.rs @@ -47,9 +47,7 @@ use relay_event_schema::protocol::{Event, EventId}; use serde::Deserialize; use serde_json::Deserializer; -use crate::extract_from_transaction::{ - extract_sdk_metadata, extract_transaction_metadata, extract_transaction_tags, -}; +use crate::extract_from_transaction::{extract_transaction_metadata, extract_transaction_tags}; pub use crate::error::ProfileError; pub use crate::outcomes::discard_reason; @@ -157,23 +155,16 @@ pub fn expand_profile(payload: &[u8], event: &Event) -> Result<(ProfileId, Vec sample::v1::parse_sample_profile( - payload, - client_sdk, - transaction_metadata, - transaction_tags, - ), + sample::Version::V1 => { + sample::v1::parse_sample_profile(payload, transaction_metadata, transaction_tags) + } _ => match profile.platform.as_str() { - "android" => android::parse_android_profile( - payload, - client_sdk, - transaction_metadata, - transaction_tags, - ), + "android" => { + android::parse_android_profile(payload, transaction_metadata, transaction_tags) + } _ => return Err(ProfileError::PlatformNotSupported), }, }; diff --git a/relay-profiling/src/sample/v1.rs b/relay-profiling/src/sample/v1.rs index 19ccacadfb..1a0dd398b1 100644 --- a/relay-profiling/src/sample/v1.rs +++ b/relay-profiling/src/sample/v1.rs @@ -326,14 +326,11 @@ fn parse_profile(payload: &[u8]) -> Result { pub fn parse_sample_profile( payload: &[u8], - client_sdk: Option, transaction_metadata: BTreeMap, transaction_tags: BTreeMap, ) -> Result, ProfileError> { let mut profile = parse_profile(payload)?; - profile.metadata.client_sdk = client_sdk; - if let Some(transaction_name) = transaction_metadata.get("transaction") { if let Some(ref mut transaction) = profile.metadata.transaction { transaction_name.clone_into(&mut transaction.name) @@ -361,6 +358,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; @@ -384,7 +391,7 @@ mod tests { #[test] fn test_expand() { let payload = include_bytes!("../../tests/fixtures/sample/v1/valid.json"); - let profile = parse_sample_profile(payload, None, BTreeMap::new(), BTreeMap::new()); + let profile = parse_sample_profile(payload, BTreeMap::new(), BTreeMap::new()); assert!(profile.is_ok()); } @@ -601,7 +608,7 @@ mod tests { ]); let payload = serde_json::to_vec(&profile).unwrap(); - let data = parse_sample_profile(&payload[..], None, BTreeMap::new(), BTreeMap::new()); + let data = parse_sample_profile(&payload[..], BTreeMap::new(), BTreeMap::new()); assert!(data.is_err()); } @@ -881,8 +888,7 @@ mod tests { )]); let payload = include_bytes!("../../tests/fixtures/sample/v1/valid.json"); - let profile_json = - parse_sample_profile(payload, None, transaction_metadata, BTreeMap::new()); + let profile_json = parse_sample_profile(payload, transaction_metadata, BTreeMap::new()); assert!(profile_json.is_ok()); let payload = profile_json.unwrap(); From 434d5b904138f2270623f46d3f6805c463b5d188 Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Fri, 9 Aug 2024 17:17:13 -0400 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 0cd037e99bdc6e1d52eba568713d52f0ac88b2ca Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Mon, 12 Aug 2024 10:47:07 -0400 Subject: [PATCH 4/4] address PR comments --- relay-profiling/src/android.rs | 7 ++++++- relay-profiling/src/client_sdk.rs | 7 ------- relay-profiling/src/lib.rs | 1 - relay-profiling/src/sample/v1.rs | 7 ++++++- relay-profiling/src/sample/v2.rs | 7 ++++++- 5 files changed, 18 insertions(+), 11 deletions(-) delete mode 100644 relay-profiling/src/client_sdk.rs diff --git a/relay-profiling/src/android.rs b/relay-profiling/src/android.rs index c66940946a..b1c54b6386 100644 --- a/relay-profiling/src/android.rs +++ b/relay-profiling/src/android.rs @@ -14,7 +14,6 @@ use data_encoding::BASE64_NOPAD; use relay_event_schema::protocol::{EventId, SpanId}; use serde::{Deserialize, Serialize}; -use crate::client_sdk::ClientSdk; use crate::measurements::Measurement; use crate::native_debug_image::NativeDebugImage; use crate::sample::v1::SampleProfile; @@ -97,6 +96,12 @@ pub struct ProfileMetadata { client_sdk: Option, } +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct ClientSdk { + name: String, + version: String, +} + #[derive(Debug, Serialize, Deserialize, Clone)] struct AndroidProfilingEvent { #[serde(flatten)] diff --git a/relay-profiling/src/client_sdk.rs b/relay-profiling/src/client_sdk.rs deleted file mode 100644 index f15d33e827..0000000000 --- a/relay-profiling/src/client_sdk.rs +++ /dev/null @@ -1,7 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct ClientSdk { - pub name: String, - pub version: String, -} diff --git a/relay-profiling/src/lib.rs b/relay-profiling/src/lib.rs index 8a895a227b..ce072a5fed 100644 --- a/relay-profiling/src/lib.rs +++ b/relay-profiling/src/lib.rs @@ -53,7 +53,6 @@ pub use crate::error::ProfileError; pub use crate::outcomes::discard_reason; mod android; -mod client_sdk; mod error; mod extract_from_transaction; mod measurements; diff --git a/relay-profiling/src/sample/v1.rs b/relay-profiling/src/sample/v1.rs index 1a0dd398b1..e3f32ff20d 100644 --- a/relay-profiling/src/sample/v1.rs +++ b/relay-profiling/src/sample/v1.rs @@ -12,7 +12,6 @@ use itertools::Itertools; use relay_event_schema::protocol::{EventId, SpanId}; use serde::{Deserialize, Serialize}; -use crate::client_sdk::ClientSdk; use crate::error::ProfileError; use crate::measurements::Measurement; use crate::sample::{DebugMeta, Frame, ThreadMetadata, Version}; @@ -261,6 +260,12 @@ pub struct ProfileMetadata { pub client_sdk: Option, } +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct ClientSdk { + name: String, + version: String, +} + #[derive(Debug, Serialize, Deserialize, Clone)] pub struct ProfilingEvent { #[serde(default, skip_serializing_if = "Option::is_none")] diff --git a/relay-profiling/src/sample/v2.rs b/relay-profiling/src/sample/v2.rs index 8573b6adad..d5b5832c59 100644 --- a/relay-profiling/src/sample/v2.rs +++ b/relay-profiling/src/sample/v2.rs @@ -16,7 +16,6 @@ use serde::{Deserialize, Serialize}; use relay_event_schema::protocol::EventId; use relay_metrics::FiniteF64; -use crate::client_sdk::ClientSdk; use crate::error::ProfileError; use crate::measurements::Measurement; use crate::sample::{DebugMeta, Frame, ThreadMetadata, Version}; @@ -43,6 +42,12 @@ pub struct ProfileMetadata { pub version: Version, } +#[derive(Debug, Serialize, Deserialize)] +pub struct ClientSdk { + name: String, + version: String, +} + #[derive(Debug, Serialize, Deserialize)] pub struct Sample { /// Unix timestamp in seconds with millisecond precision when the sample