Skip to content

Commit

Permalink
fix(profiling): set segment_id as optional (#3275)
Browse files Browse the repository at this point in the history
`segment_id` is not passed by the SDK.
  • Loading branch information
viglia authored Mar 15, 2024
1 parent e51540d commit d991a13
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**:

Expand Down
2 changes: 1 addition & 1 deletion relay-profiling/src/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}

Expand Down
12 changes: 6 additions & 6 deletions relay-profiling/src/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}

Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions relay-profiling/src/transaction_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SpanId>,

#[serde(default, deserialize_with = "deserialize_number_from_string")]
pub active_thread_id: u64,
Expand Down Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand All @@ -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());
}
Expand Down

0 comments on commit d991a13

Please sign in to comment.