Skip to content

Commit

Permalink
instr(spans): Measure span metrics extraction time (#2373)
Browse files Browse the repository at this point in the history
In preparation of #2355, measure
how much time span metrics extraction currently costs.
  • Loading branch information
jjbayer committed Aug 2, 2023
1 parent 5b63e88 commit a8e11c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion relay-server/src/metrics_extraction/spans/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::metrics_extraction::spans::types::SpanMetric;

use crate::metrics_extraction::transactions::types::ExtractMetricsError;
use crate::metrics_extraction::IntoMetric;
use crate::statsd::RelayTimers;

mod types;

Expand All @@ -21,7 +22,15 @@ pub(crate) fn extract_span_metrics(
aggregator_config: &AggregatorConfig,
event: &Event,
) -> Result<Vec<Metric>, ExtractMetricsError> {
// TODO(iker): measure the performance of this whole method
relay_statsd::metric!(timer(RelayTimers::EventProcessingSpanMetricsExtraction), {
extract_span_metrics_inner(aggregator_config, event)
})
}

fn extract_span_metrics_inner(
aggregator_config: &AggregatorConfig,
event: &Event,
) -> Result<Vec<Metric>, ExtractMetricsError> {
let mut metrics = Vec::new();

if event.ty.value() != Some(&EventType::Transaction) {
Expand Down
5 changes: 5 additions & 0 deletions relay-server/src/statsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ pub enum RelayTimers {
EventProcessingPii,
/// Time spent converting the event from its in-memory reprsentation into a JSON string.
EventProcessingSerialization,
/// Time used to extract span metrics from an event.
EventProcessingSpanMetricsExtraction,
/// Time spent between the start of request handling and processing of the envelope.
///
/// This includes streaming the request body, scheduling overheads, project config fetching,
Expand Down Expand Up @@ -329,6 +331,9 @@ impl TimerMetric for RelayTimers {
#[cfg(feature = "processing")]
RelayTimers::EventProcessingRateLimiting => "event_processing.rate_limiting",
RelayTimers::EventProcessingPii => "event_processing.pii",
RelayTimers::EventProcessingSpanMetricsExtraction => {
"event_processing.span_metrics_extraction"
}
RelayTimers::EventProcessingSerialization => "event_processing.serialization",
RelayTimers::EnvelopeWaitTime => "event.wait_time",
RelayTimers::EnvelopeProcessingTime => "event.processing_time",
Expand Down

0 comments on commit a8e11c0

Please sign in to comment.