diff --git a/CHANGELOG.md b/CHANGELOG.md index 8328a8462f..ad6f0535f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ **Bug Fixes**: - Report invalid spans with appropriate outcome reason. ([#4051](https://github.com/getsentry/relay/pull/4051)) +- Use the duration reported by the profiler instead of the transaction. ([#4058](https://github.com/getsentry/relay/pull/4058)) **Features:** diff --git a/relay-profiling/src/android.rs b/relay-profiling/src/android.rs index b1c54b6386..8f1f9703cc 100644 --- a/relay-profiling/src/android.rs +++ b/relay-profiling/src/android.rs @@ -153,7 +153,7 @@ impl AndroidProfilingEvent { } fn has_transaction_metadata(&self) -> bool { - !self.metadata.transaction_name.is_empty() && self.metadata.duration_ns > 0 + !self.metadata.transaction_name.is_empty() } } @@ -170,7 +170,6 @@ fn parse_profile(payload: &[u8]) -> Result // this is for compatibility profile.metadata.active_thread_id = transaction.active_thread_id; - profile.metadata.duration_ns = transaction.duration_ns(); profile.metadata.trace_id = transaction.trace_id; profile.metadata.transaction_id = transaction.id; profile @@ -207,6 +206,9 @@ fn parse_profile(payload: &[u8]) -> Result return Err(ProfileError::DurationIsTooLong); } + // Use duration given by the profiler and not reported by the SDK. + profile.metadata.duration_ns = profile.profile.elapsed_time.as_nanos() as u64; + Ok(profile) } @@ -320,7 +322,6 @@ mod tests { ); assert_eq!(profile.metadata.active_thread_id, 12345); assert_eq!(profile.metadata.transaction_name, "transaction1"); - assert_eq!(profile.metadata.duration_ns, 1000000000); } #[test] diff --git a/relay-profiling/src/transaction_metadata.rs b/relay-profiling/src/transaction_metadata.rs index d6c6a7eb3c..9af659adda 100644 --- a/relay-profiling/src/transaction_metadata.rs +++ b/relay-profiling/src/transaction_metadata.rs @@ -46,10 +46,6 @@ impl TransactionMetadata { pub fn valid(&self) -> bool { !self.id.is_nil() && !self.name.is_empty() && !self.trace_id.is_nil() } - - pub fn duration_ns(&self) -> u64 { - self.relative_end_ns.saturating_sub(self.relative_start_ns) - } } #[cfg(test)]