Skip to content

Commit 5aeab99

Browse files
committed
feat: add metrics
1 parent 3ea6a60 commit 5aeab99

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

crates/batcher/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ impl Batcher {
664664
"Failed to acquire batch lock when trying to remove proofs from user {:?}, skipping removal",
665665
user_address
666666
);
667-
// TODO metrics for batch lock timeout during event processing
667+
self.metrics.inc_unlocked_event_polling_batch_lock_timeout();
668668
return;
669669
}
670670
};

crates/batcher/src/metrics.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub struct BatcherMetrics {
3030
pub message_handler_user_lock_timeouts: IntCounter,
3131
pub message_handler_batch_lock_timeouts: IntCounter,
3232
pub message_handler_user_states_lock_timeouts: IntCounter,
33+
pub unlocked_event_polling_batch_lock_timeouts: IntCounter,
3334
pub available_data_services: IntGauge,
3435
}
3536

@@ -103,6 +104,11 @@ impl BatcherMetrics {
103104
"Message Handler User States Lock Timeouts"
104105
))?;
105106

107+
let unlocked_event_polling_batch_lock_timeouts = register_int_counter!(opts!(
108+
"unlocked_event_polling_batch_lock_timeouts_count",
109+
"Unlocked Event Polling Batch Lock Timeouts"
110+
))?;
111+
106112
registry.register(Box::new(open_connections.clone()))?;
107113
registry.register(Box::new(received_proofs.clone()))?;
108114
registry.register(Box::new(sent_batches.clone()))?;
@@ -122,6 +128,7 @@ impl BatcherMetrics {
122128
registry.register(Box::new(message_handler_user_lock_timeouts.clone()))?;
123129
registry.register(Box::new(message_handler_batch_lock_timeouts.clone()))?;
124130
registry.register(Box::new(message_handler_user_states_lock_timeouts.clone()))?;
131+
registry.register(Box::new(unlocked_event_polling_batch_lock_timeouts.clone()))?;
125132
registry.register(Box::new(available_data_services.clone()))?;
126133

127134
let metrics_route = warp::path!("metrics")
@@ -154,6 +161,7 @@ impl BatcherMetrics {
154161
message_handler_user_lock_timeouts,
155162
message_handler_batch_lock_timeouts,
156163
message_handler_user_states_lock_timeouts,
164+
unlocked_event_polling_batch_lock_timeouts,
157165
available_data_services,
158166
})
159167
}
@@ -200,4 +208,8 @@ impl BatcherMetrics {
200208
pub fn inc_message_handler_user_states_lock_timeouts(&self) {
201209
self.message_handler_user_states_lock_timeouts.inc();
202210
}
211+
212+
pub fn inc_unlocked_event_polling_batch_lock_timeout(&self) {
213+
self.unlocked_event_polling_batch_lock_timeouts.inc();
214+
}
203215
}

0 commit comments

Comments
 (0)