diff --git a/CHANGELOG.md b/CHANGELOG.md index ef587802ef..44de803bc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - Do not PII-scrub code locations by default. ([#3116](https://github.com/getsentry/relay/pull/3116)) - Accept transactions with unfinished spans. ([#3162](https://github.com/getsentry/relay/pull/3162)) - Don't run validation on renormalization, and don't normalize spans from librelay calls. ([#3214](https://github.com/getsentry/relay/pull/3214)) +- Set segment_id as optional ([#3275](https://github.com/getsentry/relay/pull/3275)) **Internal**: diff --git a/relay-profiling/src/android.rs b/relay-profiling/src/android.rs index df8b063f84..eecb6d0248 100644 --- a/relay-profiling/src/android.rs +++ b/relay-profiling/src/android.rs @@ -219,7 +219,7 @@ pub fn parse_android_profile( if let Some(segment_id) = transaction_metadata.get("segment_id") { if let Some(transaction_metadata) = profile.metadata.transaction.as_mut() { - transaction_metadata.segment_id = SpanId(segment_id.to_owned()); + transaction_metadata.segment_id = Some(SpanId(segment_id.to_owned())); } } diff --git a/relay-profiling/src/sample.rs b/relay-profiling/src/sample.rs index 75e83d6310..5ac3081ba3 100644 --- a/relay-profiling/src/sample.rs +++ b/relay-profiling/src/sample.rs @@ -395,7 +395,7 @@ pub fn parse_sample_profile( if let Some(segment_id) = transaction_metadata.get("segment_id") { if let Some(transaction_metadata) = profile.metadata.transaction.as_mut() { - transaction_metadata.segment_id = SpanId(segment_id.to_owned()); + transaction_metadata.segment_id = Some(SpanId(segment_id.to_owned())); } } @@ -557,7 +557,7 @@ mod tests { relative_end_ns: 30, relative_start_ns: 10, trace_id: EventId::new(), - segment_id: SpanId("bd2eb23da2beb459".to_string()), + segment_id: Some(SpanId("bd2eb23da2beb459".to_string())), }); profile.profile.stacks.push(vec![0]); profile.profile.samples.extend(vec![ @@ -609,7 +609,7 @@ mod tests { relative_end_ns: 100, relative_start_ns: 50, trace_id: EventId::new(), - segment_id: SpanId("bd2eb23da2beb459".to_string()), + segment_id: Some(SpanId("bd2eb23da2beb459".to_string())), }); profile.profile.stacks.push(vec![0]); profile.profile.samples.extend(vec![ @@ -657,7 +657,7 @@ mod tests { relative_end_ns: 100, relative_start_ns: 0, trace_id: EventId::new(), - segment_id: SpanId("bd2eb23da2beb459".to_string()), + segment_id: Some(SpanId("bd2eb23da2beb459".to_string())), }; profile.metadata.transactions.push(transaction.clone()); @@ -718,7 +718,7 @@ mod tests { relative_end_ns: 100, relative_start_ns: 0, trace_id: EventId::new(), - segment_id: SpanId("bd2eb23da2beb459".to_string()), + segment_id: Some(SpanId("bd2eb23da2beb459".to_string())), }; profile.metadata.transaction = Some(transaction); @@ -832,7 +832,7 @@ mod tests { relative_end_ns: 100, relative_start_ns: 0, trace_id: EventId::new(), - segment_id: SpanId("bd2eb23da2beb459".to_string()), + segment_id: Some(SpanId("bd2eb23da2beb459".to_string())), }; profile.metadata.transaction = Some(transaction); diff --git a/relay-profiling/src/transaction_metadata.rs b/relay-profiling/src/transaction_metadata.rs index 6b71d918a8..d6c6a7eb3c 100644 --- a/relay-profiling/src/transaction_metadata.rs +++ b/relay-profiling/src/transaction_metadata.rs @@ -8,7 +8,8 @@ pub struct TransactionMetadata { pub id: EventId, pub name: String, pub trace_id: EventId, - pub segment_id: SpanId, + #[serde(skip_serializing_if = "Option::is_none")] + pub segment_id: Option, #[serde(default, deserialize_with = "deserialize_number_from_string")] pub active_thread_id: u64, @@ -66,7 +67,7 @@ mod tests { relative_end_ns: 133, relative_start_ns: 1, trace_id: "4705BD13-368A-499A-AA48-439DAFD9CFB0".parse().unwrap(), - segment_id: SpanId("bd2eb23da2beb459".to_string()), + segment_id: Some(SpanId("bd2eb23da2beb459".to_string())), }; assert!(metadata.valid()); } @@ -82,7 +83,7 @@ mod tests { relative_end_ns: 133, relative_start_ns: 1, trace_id: "4705BD13-368A-499A-AA48-439DAFD9CFB0".parse().unwrap(), - segment_id: SpanId("bd2eb23da2beb459".to_string()), + segment_id: Some(SpanId("bd2eb23da2beb459".to_string())), }; assert!(!metadata.valid()); } @@ -98,7 +99,7 @@ mod tests { relative_end_ns: 0, relative_start_ns: 0, trace_id: "4705BD13-368A-499A-AA48-439DAFD9CFB0".parse().unwrap(), - segment_id: SpanId("bd2eb23da2beb459".to_string()), + segment_id: Some(SpanId("bd2eb23da2beb459".to_string())), }; assert!(metadata.valid()); }