From c31d2a15f119ceea0d25181b18de20f19de1682c Mon Sep 17 00:00:00 2001 From: Jerome Gravel-Niquet Date: Fri, 29 Nov 2024 14:24:26 -0500 Subject: [PATCH] measure how many changes get dropped --- crates/corro-agent/src/agent/handlers.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/corro-agent/src/agent/handlers.rs b/crates/corro-agent/src/agent/handlers.rs index 68ba077e..872d7bee 100644 --- a/crates/corro-agent/src/agent/handlers.rs +++ b/crates/corro-agent/src/agent/handlers.rs @@ -888,6 +888,7 @@ pub async fn handle_changes( // drop old items when the queue is full. if queue.len() >= max_queue_len { + let mut dropped_count = 0; if let Some((dropped_change, _, _)) = queue.pop_front() { for v in dropped_change.versions() { if let Entry::Occupied(mut entry) = seen.entry((change.actor_id, v)) { @@ -900,7 +901,9 @@ pub async fn handle_changes( } buf_cost -= dropped_change.processing_cost(); + dropped_count += 1; } + counter!("corro.agent.changes.dropped").increment(dropped_count); log_at_pow_10("dropped old change from queue", &mut drop_log_count); }