Skip to content

Commit ab5f3ec

Browse files
committed
Fix: Apply first timestamp delta in StreamingProfilePacket processing
Remove the 'i > 0' guard that was skipping timestamp_delta_us[0] for the first sample. Per the Perfetto spec, the absolute timestamp of the first sample should be TracePacket.timestamp + timestamp_delta_us[0], not just TracePacket.timestamp. This bug was masked in tests that use 0 as the first delta, but would affect real production traces with non-zero first deltas.
1 parent 49f3bd9 commit ab5f3ec

File tree

1 file changed

+1
-3
lines changed
  • relay-profiling/src/perfetto

1 file changed

+1
-3
lines changed

relay-profiling/src/perfetto/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,7 @@ pub fn convert(perfetto_bytes: &[u8]) -> Result<(ProfileData, Vec<DebugImage>),
229229
Some(Data::StreamingProfilePacket(spp)) => {
230230
let mut ts = packet.timestamp.unwrap_or(0);
231231
for (i, &cs_iid) in spp.callstack_iid.iter().enumerate() {
232-
if i > 0
233-
&& let Some(&delta) = spp.timestamp_delta_us.get(i)
234-
{
232+
if let Some(&delta) = spp.timestamp_delta_us.get(i) {
235233
// `delta` is i64 (can be negative for out-of-order samples).
236234
// Casting to u64 wraps negative values, which is correct because
237235
// `wrapping_add` of a wrapped negative value subtracts as expected.

0 commit comments

Comments
 (0)