Skip to content

Commit

Permalink
ref(project-cache): Add timing metric for project cache (#3103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde authored Feb 14, 2024
1 parent 1a780e2 commit 26edcb1
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 17 deletions.
64 changes: 47 additions & 17 deletions relay-server/src/services/project_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,25 @@ pub enum ProjectCache {
RefreshIndexCache(RefreshIndexCache),
}

impl ProjectCache {
pub fn variant(&self) -> &'static str {
match self {
Self::RequestUpdate(_) => "RequestUpdate",
Self::Get(_, _) => "Get",
Self::GetCached(_, _) => "GetCached",
Self::CheckEnvelope(_, _) => "CheckEnvelope",
Self::ValidateEnvelope(_) => "ValidateEnvelope",
Self::UpdateRateLimits(_) => "UpdateRateLimits",
Self::MergeBuckets(_) => "MergeBuckets",
Self::AddMetricMeta(_) => "AddMetricMeta",
Self::FlushBuckets(_) => "FlushBuckets",
Self::UpdateSpoolIndex(_) => "UpdateSpoolIndex",
Self::SpoolHealth(_) => "SpoolHealth",
Self::RefreshIndexCache(_) => "RefreshIndexCache",
}
}
}

impl Interface for ProjectCache {}

impl FromMessage<UpdateSpoolIndex> for ProjectCache {
Expand Down Expand Up @@ -943,24 +962,35 @@ impl ProjectCacheBroker {
}

fn handle_message(&mut self, message: ProjectCache) {
match message {
ProjectCache::RequestUpdate(message) => self.handle_request_update(message),
ProjectCache::Get(message, sender) => self.handle_get(message, sender),
ProjectCache::GetCached(message, sender) => {
sender.send(self.handle_get_cached(message))
}
ProjectCache::CheckEnvelope(message, sender) => {
sender.send(self.handle_check_envelope(message))
let ty = message.variant();
metric!(
timer(RelayTimers::ProjectCacheMessageDuration),
message = ty,
{
match message {
ProjectCache::RequestUpdate(message) => self.handle_request_update(message),
ProjectCache::Get(message, sender) => self.handle_get(message, sender),
ProjectCache::GetCached(message, sender) => {
sender.send(self.handle_get_cached(message))
}
ProjectCache::CheckEnvelope(message, sender) => {
sender.send(self.handle_check_envelope(message))
}
ProjectCache::ValidateEnvelope(message) => {
self.handle_validate_envelope(message)
}
ProjectCache::UpdateRateLimits(message) => self.handle_rate_limits(message),
ProjectCache::MergeBuckets(message) => self.handle_merge_buckets(message),
ProjectCache::AddMetricMeta(message) => self.handle_add_metric_meta(message),
ProjectCache::FlushBuckets(message) => self.handle_flush_buckets(message),
ProjectCache::UpdateSpoolIndex(message) => self.handle_buffer_index(message),
ProjectCache::SpoolHealth(sender) => self.handle_spool_health(sender),
ProjectCache::RefreshIndexCache(message) => {
self.handle_refresh_index_cache(message)
}
}
}
ProjectCache::ValidateEnvelope(message) => self.handle_validate_envelope(message),
ProjectCache::UpdateRateLimits(message) => self.handle_rate_limits(message),
ProjectCache::MergeBuckets(message) => self.handle_merge_buckets(message),
ProjectCache::AddMetricMeta(message) => self.handle_add_metric_meta(message),
ProjectCache::FlushBuckets(message) => self.handle_flush_buckets(message),
ProjectCache::UpdateSpoolIndex(message) => self.handle_buffer_index(message),
ProjectCache::SpoolHealth(sender) => self.handle_spool_health(sender),
ProjectCache::RefreshIndexCache(message) => self.handle_refresh_index_cache(message),
}
)
}
}

Expand Down
6 changes: 6 additions & 0 deletions relay-server/src/statsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ pub enum RelayTimers {
///
/// - `message`: The type of message that was processed.
ProcessMessageDuration,
/// Timing in milliseconds for handling a project cache message.
///
/// This metric is tagged with:
/// - `message`: The type of message that was processed.
ProjectCacheMessageDuration,
/// Timing in milliseconds for processing a message in the buffer service.
///
/// This metric is tagged with:
Expand Down Expand Up @@ -389,6 +394,7 @@ impl TimerMetric for RelayTimers {
RelayTimers::ReplayRecordingProcessing => "replay.recording.process",
RelayTimers::GlobalConfigRequestDuration => "global_config.requests.duration",
RelayTimers::ProcessMessageDuration => "processor.message.duration",
RelayTimers::ProjectCacheMessageDuration => "project_cache.message.duration",
RelayTimers::BufferMessageProcessDuration => "buffer.message.duration",
}
}
Expand Down

0 comments on commit 26edcb1

Please sign in to comment.