Skip to content

Commit 9b19609

Browse files
authored
ref(instr): Instrument rate limit timings for new processing pipeline (#5389)
1 parent 0e064e7 commit 9b19609

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

relay-server/src/processing/limits.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::processing::{Context, Counted, Managed, Rejected};
99
use crate::services::{
1010
global_rate_limits::GlobalRateLimitsServiceHandle, projects::cache::ProjectCacheHandle,
1111
};
12+
use crate::statsd::RelayTimers;
1213

1314
#[cfg(feature = "processing")]
1415
type Redis = relay_quotas::RedisRateLimiter<GlobalRateLimitsServiceHandle>;
@@ -71,7 +72,21 @@ impl QuotaRateLimiter {
7172
redis::CombinedRateLimiter(limiter, redis)
7273
};
7374

74-
data.enforce(limiter, ctx).await
75+
let ty = match self.has_redis() {
76+
true => "consistent",
77+
false => "cached",
78+
};
79+
relay_statsd::metric!(timer(RelayTimers::EventProcessingRateLimiting), type = ty, unit = std::any::type_name::<T>(), {
80+
data.enforce(limiter, ctx).await
81+
})
82+
}
83+
84+
fn has_redis(&self) -> bool {
85+
#[cfg(feature = "processing")]
86+
if self.redis.is_some() {
87+
return true;
88+
}
89+
false
7590
}
7691
}
7792

relay-server/src/statsd.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ pub enum RelayTimers {
389389
///
390390
/// This metric is tagged with:
391391
/// - `type`: The type of limiter executed, `cached` or `consistent`.
392+
/// - `unit`: The item/unit of work which is being rate limited, only available for new
393+
/// processing pipelines.
392394
EventProcessingRateLimiting,
393395
/// Time in milliseconds spent in data scrubbing for the current event. Data scrubbing happens
394396
/// last before serializing the event back to JSON.

0 commit comments

Comments
 (0)