Skip to content

Commit

Permalink
instr(server): Measure nested span count (#4221)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjbayer authored Nov 6, 2024
1 parent 0a62501 commit 277c54d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion relay-server/src/services/projects/cache/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions relay-server/src/statsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
}
}
}
Expand Down

0 comments on commit 277c54d

Please sign in to comment.