Skip to content

Commit 4c762d5

Browse files
committed
Record how long it takes to wait for a writer connection to become available.
1 parent 5f770e5 commit 4c762d5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

crates/syn2mas/src/mas_writer/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ use self::{
3131
constraint_pausing::{ConstraintDescription, IndexDescription},
3232
locking::LockedMasDatabase,
3333
};
34-
use crate::{Progress, telemetry::WRITER_FLUSH_TIME};
34+
use crate::{
35+
Progress,
36+
telemetry::{WRITER_FLUSH_TIME, WRITER_WAIT_TIME},
37+
};
3538

3639
pub mod checks;
3740
pub mod locking;
@@ -119,8 +122,12 @@ impl WriterConnectionPool {
119122
+ Sync
120123
+ 'static,
121124
{
125+
let start = Instant::now();
122126
match self.connection_rx.recv().await {
123127
Some(Ok(mut connection)) => {
128+
let elapsed = start.elapsed();
129+
WRITER_WAIT_TIME.record(elapsed.as_millis().try_into().unwrap_or(u64::MAX), &[]);
130+
124131
let connection_tx = self.connection_tx.clone();
125132
tokio::task::spawn(
126133
async move {

crates/syn2mas/src/telemetry.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ pub static WRITER_FLUSH_TIME: LazyLock<Histogram<u64>> = LazyLock::new(|| {
4545
.build()
4646
});
4747

48+
pub static WRITER_WAIT_TIME: LazyLock<Histogram<u64>> = LazyLock::new(|| {
49+
METER
50+
.u64_histogram("syn2mas.writer.wait_time")
51+
.with_description("Time spent waiting for a writer connection to become available")
52+
.with_unit("ms")
53+
.build()
54+
});
55+
4856
/// Attribute key for syn2mas.entity metrics representing what entity.
4957
pub const K_ENTITY: &str = "entity";
5058

0 commit comments

Comments
 (0)