diff --git a/relay-server/src/services/store.rs b/relay-server/src/services/store.rs index 7b49df47df..763ce3d7a1 100644 --- a/relay-server/src/services/store.rs +++ b/relay-server/src/services/store.rs @@ -35,7 +35,7 @@ use crate::service::ServiceError; use crate::services::global_config::GlobalConfigHandle; use crate::services::outcome::{DiscardReason, Outcome, TrackOutcome}; use crate::services::processor::Processed; -use crate::statsd::RelayCounters; +use crate::statsd::{RelayCounters, RelayTimers}; use crate::utils::{is_rolled_out, FormDataIter, TypedEnvelope}; /// Fallback name used for attachment items without a `filename` header. @@ -101,6 +101,17 @@ pub enum Store { Cogs(StoreCogs), } +impl Store { + /// Returns the name of the message variant. + fn variant(&self) -> &'static str { + match self { + Store::Envelope(_) => "envelope", + Store::Metrics(_) => "metrics", + Store::Cogs(_) => "cogs", + } + } +} + impl Interface for Store {} impl FromMessage for Store { @@ -154,11 +165,14 @@ impl StoreService { } fn handle_message(&self, message: Store) { - match message { - Store::Envelope(message) => self.handle_store_envelope(message), - Store::Metrics(message) => self.handle_store_metrics(message), - Store::Cogs(message) => self.handle_store_cogs(message), - } + let ty = message.variant(); + relay_statsd::metric!(timer(RelayTimers::StoreServiceDuration), message = ty, { + match message { + Store::Envelope(message) => self.handle_store_envelope(message), + Store::Metrics(message) => self.handle_store_metrics(message), + Store::Cogs(message) => self.handle_store_cogs(message), + } + }) } fn handle_store_envelope(&self, message: StoreEnvelope) { diff --git a/relay-server/src/statsd.rs b/relay-server/src/statsd.rs index 757f7559db..38587ad45b 100644 --- a/relay-server/src/statsd.rs +++ b/relay-server/src/statsd.rs @@ -527,6 +527,12 @@ pub enum RelayTimers { /// This metric is tagged with: /// - `message`: The type of message that was processed. MetricRouterServiceDuration, + /// Timing in milliseconds for processing a message in the metric store service. + /// + /// This metric is tagged with: + /// - `message`: The type of message that was processed. + #[cfg(feature = "processing")] + StoreServiceDuration, } impl TimerMetric for RelayTimers { @@ -566,6 +572,8 @@ impl TimerMetric for RelayTimers { RelayTimers::RateLimitBucketsDuration => "processor.rate_limit_buckets", RelayTimers::AggregatorServiceDuration => "metrics.aggregator.message.duration", RelayTimers::MetricRouterServiceDuration => "metrics.router.message.duration", + #[cfg(feature = "processing")] + RelayTimers::StoreServiceDuration => "store.message.duration", } } }