Skip to content

Commit

Permalink
instr(buffer): Measure envelope size
Browse files Browse the repository at this point in the history
  • Loading branch information
jjbayer committed Oct 18, 2024
1 parent 6a76476 commit c4fcff5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions relay-server/src/services/buffer/envelope_buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ impl PolymorphicEnvelopeBuffer {

/// Adds an envelope to the buffer.
pub async fn push(&mut self, envelope: Box<Envelope>) -> Result<(), EnvelopeBufferError> {
relay_statsd::metric!(
histogram(RelayHistograms::BufferEnvelopeBodySize) =
envelope.items().map(Item::len).sum()
);

relay_statsd::metric!(timer(RelayTimers::BufferPush), {
match self {
Self::Sqlite(buffer) => buffer.push(envelope).await,
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 @@ -181,6 +181,11 @@ pub enum RelayHistograms {
/// Number of envelopes in the backpressure buffer between the envelope buffer
/// and the project cache.
BufferBackpressureEnvelopesCount,
/// The amount of bytes in the item payloads of an envelope pushed to the envelope buffer.
///
/// This is not quite the same as the actual size of a serialized envelope, because it ignores
/// the envelope header and item headers.
BufferEnvelopeBodySize,
/// The number of batches emitted per partition.
BatchesPerPartition,
/// The number of buckets in a batch emitted.
Expand Down Expand Up @@ -309,6 +314,7 @@ impl HistogramMetric for RelayHistograms {
RelayHistograms::BufferBackpressureEnvelopesCount => {
"buffer.backpressure_envelopes_count"
}
RelayHistograms::BufferEnvelopeBodySize => "buffer.envelope_body_size",
RelayHistograms::ProjectStatePending => "project_state.pending",
RelayHistograms::ProjectStateAttempts => "project_state.attempts",
RelayHistograms::ProjectStateRequestBatchSize => "project_state.request.batch_size",
Expand Down

0 comments on commit c4fcff5

Please sign in to comment.