From 277c54d3ddcae1a6c172afcc958efc6c21d7190e Mon Sep 17 00:00:00 2001 From: Joris Bayer Date: Wed, 6 Nov 2024 10:20:18 +0100 Subject: [PATCH] instr(server): Measure nested span count (#4221) --- relay-server/src/services/projects/cache/project.rs | 5 ++++- relay-server/src/statsd.rs | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/relay-server/src/services/projects/cache/project.rs b/relay-server/src/services/projects/cache/project.rs index 4b9e95a2be..70a7909398 100644 --- a/relay-server/src/services/projects/cache/project.rs +++ b/relay-server/src/services/projects/cache/project.rs @@ -9,6 +9,7 @@ use crate::envelope::ItemType; use crate::services::outcome::{DiscardReason, Outcome}; use crate::services::projects::cache::state::SharedProject; use crate::services::projects::project::ProjectState; +use crate::statsd::RelayTimers; use crate::utils::{CheckLimits, Enforcement, EnvelopeLimiter, ManagedEnvelope}; /// A loaded project. @@ -90,7 +91,9 @@ impl<'a> Project<'a> { // If we can extract spans from the event, we want to try and count the number of nested // spans to correctly emit negative outcomes in case the transaction itself is dropped. if check_nested_spans { - sync_spans_to_enforcement(&envelope, &mut enforcement); + relay_statsd::metric!(timer(RelayTimers::CheckNestedSpans), { + sync_spans_to_enforcement(&envelope, &mut enforcement); + }); } enforcement.apply_with_outcomes(&mut envelope); diff --git a/relay-server/src/statsd.rs b/relay-server/src/statsd.rs index 1810e8fc51..9a93a07ef2 100644 --- a/relay-server/src/statsd.rs +++ b/relay-server/src/statsd.rs @@ -553,6 +553,8 @@ pub enum RelayTimers { BufferEnvelopesSerialization, /// Timing in milliseconds to the time it takes to read an HTTP body. BodyReadDuration, + /// Timing in milliseconds to count spans in a serialized transaction payload. + CheckNestedSpans, } impl TimerMetric for RelayTimers { @@ -605,6 +607,7 @@ impl TimerMetric for RelayTimers { RelayTimers::BufferDrain => "buffer.drain.duration", RelayTimers::BufferEnvelopesSerialization => "buffer.envelopes_serialization", RelayTimers::BodyReadDuration => "requests.body_read.duration", + RelayTimers::CheckNestedSpans => "envelope.check_nested_spans", } } }