Skip to content

Commit 8ad5fe7

Browse files
committed
ref: Add event size metrics
1 parent db86b75 commit 8ad5fe7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

common/src/metrics.rs

+11
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,15 @@ macro_rules! metric {
168168
});
169169
rv
170170
}};
171+
172+
// we use statsd timers to send things such as filesizes as well.
173+
(time_raw($id:expr) = $value:expr $(, $k:expr => $v:expr)* $(,)?) => {{
174+
use $crate::metrics::_pred::*;
175+
$crate::metrics::with_client(|client| {
176+
client.time_with_tags($id, $value)
177+
$(.with_tag($k, $v))*
178+
.send();
179+
})
180+
}};
181+
171182
}

server/src/body/store_body.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use flate2::read::ZlibDecoder;
1212
use futures::prelude::*;
1313
use url::form_urlencoded;
1414

15+
use semaphore_common::metric;
16+
1517
use crate::actors::outcome::DiscardReason;
1618

1719
/// A set of errors that can occur during parsing json payloads
@@ -159,7 +161,12 @@ impl Future for StoreBody {
159161
Ok(body)
160162
}
161163
})
162-
.and_then(|body| decode_bytes(body.freeze()));
164+
.and_then(|body| {
165+
metric!(time_raw("event.size_bytes.raw") = body.len() as u64);
166+
let decoded = decode_bytes(body.freeze())?;
167+
metric!(time_raw("event.size_bytes.uncompressed") = decoded.len() as u64);
168+
Ok(decoded)
169+
});
163170

164171
self.fut = Some(Box::new(future));
165172

0 commit comments

Comments
 (0)