From 8e877010a9c11ef9d52de6b7bbea31999d511ba4 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Fri, 29 Nov 2024 09:20:58 +0100 Subject: [PATCH] feat(statsd): reintroduce metrics for envelope items --- relay-server/src/endpoints/common.rs | 11 +++++++++++ relay-server/src/statsd.rs | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/relay-server/src/endpoints/common.rs b/relay-server/src/endpoints/common.rs index beee35b563..5a27950914 100644 --- a/relay-server/src/endpoints/common.rs +++ b/relay-server/src/endpoints/common.rs @@ -325,11 +325,22 @@ pub async fn handle_envelope( state: &ServiceState, envelope: Box, ) -> Result, BadStoreRequest> { + let client_name = envelope.meta().client_name(); for item in envelope.items() { metric!( histogram(RelayHistograms::EnvelopeItemSize) = item.payload().len() as u64, item_type = item.ty().name() ); + metric!( + counter(RelayCounters::EnvelopeItems) += 1, + item_type = item.ty().name(), + sdk = client_name.name(), + ); + metric!( + counter(RelayCounters::EnvelopeItemBytes) += item.payload().len() as u64, + item_type = item.ty().name(), + sdk = client_name.name(), + ); } if state.memory_checker().check_memory().is_exceeded() { diff --git a/relay-server/src/statsd.rs b/relay-server/src/statsd.rs index 257f2f4281..412e365584 100644 --- a/relay-server/src/statsd.rs +++ b/relay-server/src/statsd.rs @@ -649,6 +649,10 @@ pub enum RelayCounters { /// - `handling`: Either `"success"` if the envelope was handled correctly, or `"failure"` if /// there was an error or bug. EnvelopeRejected, + /// Number of items we processed per envelope. + EnvelopeItems, + /// Number of bytes we processed per envelope item. + EnvelopeItemBytes, /// Number of _envelopes_ the envelope buffer ingests. BufferEnvelopesWritten, /// Number of _envelopes_ the envelope buffer produces. @@ -852,6 +856,8 @@ impl CounterMetric for RelayCounters { RelayCounters::EventCorrupted => "event.corrupted", RelayCounters::EnvelopeAccepted => "event.accepted", RelayCounters::EnvelopeRejected => "event.rejected", + RelayCounters::EnvelopeItems => "event.items", + RelayCounters::EnvelopeItemBytes => "event.item_bytes", RelayCounters::BufferEnvelopesWritten => "buffer.envelopes_written", RelayCounters::BufferEnvelopesRead => "buffer.envelopes_read", RelayCounters::BufferEnvelopesReturned => "buffer.envelopes_returned",