Skip to content

Commit

Permalink
feat(spooler): Add metric to track serialization performance (#4135)
Browse files Browse the repository at this point in the history
  • Loading branch information
iambriccardo authored Oct 11, 2024
1 parent 63a8b09 commit 2f2e7d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion relay-server/src/services/buffer/envelope_stack/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ impl SqliteEnvelopeStack {

// We convert envelopes into a format which simplifies insertion in the store. If an
// envelope can't be serialized, we will not insert it.
let envelopes = envelopes.iter().filter_map(|e| e.as_ref().try_into().ok());
let envelopes = relay_statsd::metric!(timer(RelayTimers::BufferEnvelopesSerialization), {
envelopes.iter().filter_map(|e| e.as_ref().try_into().ok())
});

// When early return here, we are acknowledging that the elements that we popped from
// the buffer are lost in case of failure. We are doing this on purposes, since if we were
Expand Down
3 changes: 3 additions & 0 deletions relay-server/src/statsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,8 @@ pub enum RelayTimers {
BufferPop,
/// Timing in milliseconds for the time it takes for the buffer to drain its envelopes.
BufferDrain,
/// Timing in milliseconds for the time it takes for the envelopes to be serialized.
BufferEnvelopesSerialization,
}

impl TimerMetric for RelayTimers {
Expand Down Expand Up @@ -586,6 +588,7 @@ impl TimerMetric for RelayTimers {
RelayTimers::BufferPeek => "buffer.peek.duration",
RelayTimers::BufferPop => "buffer.pop.duration",
RelayTimers::BufferDrain => "buffer.drain.duration",
RelayTimers::BufferEnvelopesSerialization => "buffer.envelopes_serialization",
}
}
}
Expand Down

0 comments on commit 2f2e7d0

Please # to comment.