From 8fcff0b580ab5bbe58f81bf3b4d4a4a923180e90 Mon Sep 17 00:00:00 2001 From: Joris Bayer Date: Mon, 30 May 2022 14:48:28 +0200 Subject: [PATCH] feat(statsd): Measure number of project config attempts (#1281) Track a metric for how often project configs are re-attempted, either because they received a "pending" response or an error response. --- relay-server/src/actors/project_upstream.rs | 12 ++++++++++-- relay-server/src/statsd.rs | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/relay-server/src/actors/project_upstream.rs b/relay-server/src/actors/project_upstream.rs index 8e51fbd157f..6416be39f83 100644 --- a/relay-server/src/actors/project_upstream.rs +++ b/relay-server/src/actors/project_upstream.rs @@ -90,6 +90,7 @@ struct ProjectStateChannel { receiver: Shared>>, deadline: Instant, no_cache: bool, + attempts: u64, } impl ProjectStateChannel { @@ -101,6 +102,7 @@ impl ProjectStateChannel { receiver: receiver.shared(), deadline: Instant::now() + timeout, no_cache: false, + attempts: 0, } } @@ -196,7 +198,10 @@ impl UpstreamProjectSource { let requests: Vec<_> = (cache_batches.into_iter()) .chain(nocache_batches.into_iter()) .map(|channels_batch| { - let channels_batch: BTreeMap<_, _> = channels_batch.collect(); + let mut channels_batch: BTreeMap<_, _> = channels_batch.collect(); + for channel in channels_batch.values_mut() { + channel.attempts += 1; + } relay_log::debug!("sending request of size {}", channels_batch.len()); metric!( histogram(RelayHistograms::ProjectStateRequestBatchSize) = @@ -261,7 +266,10 @@ impl UpstreamProjectSource { Some(ProjectState::err()) }) .unwrap_or_else(ProjectState::missing); - + metric!( + histogram(RelayHistograms::ProjectStateAttempts) = + channel.attempts + ); channel.send(state.sanitize()); } } diff --git a/relay-server/src/statsd.rs b/relay-server/src/statsd.rs index 4031bb7f421..860d009198a 100644 --- a/relay-server/src/statsd.rs +++ b/relay-server/src/statsd.rs @@ -89,6 +89,8 @@ pub enum RelayHistograms { /// /// See `project_cache.size` for more description of the project cache. ProjectStateReceived, + /// Number of attempts required to fetch the config for a given project key. + ProjectStateAttempts, /// Number of project states currently held in the in-memory project cache. /// /// The cache duration for project states can be configured with the following options: @@ -150,6 +152,7 @@ impl HistogramMetric for RelayHistograms { RelayHistograms::RequestSizeBytesRaw => "event.size_bytes.raw", RelayHistograms::RequestSizeBytesUncompressed => "event.size_bytes.uncompressed", RelayHistograms::ProjectStatePending => "project_state.pending", + RelayHistograms::ProjectStateAttempts => "project_state.attempts", RelayHistograms::ProjectStateRequestBatchSize => "project_state.request.batch_size", RelayHistograms::ProjectStateReceived => "project_state.received", RelayHistograms::ProjectStateCacheSize => "project_cache.size",