From 47d3d5a4a8a4bda05be422b19f1b67a490a900a2 Mon Sep 17 00:00:00 2001 From: Thomas BESSOU Date: Fri, 28 Nov 2025 19:42:17 +0100 Subject: [PATCH] Make it possible to `==` `Transaction`/`Span`/`TransactionOrSpan` --- sentry-core/src/performance.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sentry-core/src/performance.rs b/sentry-core/src/performance.rs index 9b48e911..5416746e 100644 --- a/sentry-core/src/performance.rs +++ b/sentry-core/src/performance.rs @@ -402,7 +402,7 @@ pub type TracesSampler = dyn Fn(&TransactionContext) -> f32 + Send + Sync; // global API types: /// A wrapper that groups a [`Transaction`] and a [`Span`] together. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub enum TransactionOrSpan { /// A [`Transaction`]. Transaction(Transaction), @@ -958,6 +958,12 @@ impl Transaction { } } +impl PartialEq for Transaction { + fn eq(&self, other: &Self) -> bool { + Arc::ptr_eq(&self.inner, &other.inner) + } +} + /// A smart pointer to a span's [`data` field](protocol::Span::data). pub struct Data<'a>(MutexGuard<'a, protocol::Span>); @@ -1203,6 +1209,12 @@ impl Span { } } +impl PartialEq for Span { + fn eq(&self, other: &Self) -> bool { + Arc::ptr_eq(&self.span, &other.span) + } +} + /// Represents a key-value pair such as an HTTP header. pub type TraceHeader = (&'static str, String);