Skip to content

Commit

Permalink
feat(statsd): reintroduce metrics for envelope items
Browse files Browse the repository at this point in the history
  • Loading branch information
Litarnus committed Nov 29, 2024
1 parent 7904c99 commit 8e87701
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions relay-server/src/endpoints/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,22 @@ pub async fn handle_envelope(
state: &ServiceState,
envelope: Box<Envelope>,
) -> Result<Option<EventId>, 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() {
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 @@ -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.
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 8e87701

Please sign in to comment.