From 208ebff9c5259ca9d11dfcf8502d382e7444b1d6 Mon Sep 17 00:00:00 2001 From: daisuke8000 Date: Sun, 5 Jul 2026 18:03:19 +0900 Subject: [PATCH] Consolidate MuxMetrics drop instrumentation (DSK-132) Record mux drops to RunStats or the local counter, not both; mux_drop_count reads from the active source. Co-authored-by: Cursor --- crates/rustern-core/src/runtime/forward.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/rustern-core/src/runtime/forward.rs b/crates/rustern-core/src/runtime/forward.rs index e2cfbae..88253a8 100644 --- a/crates/rustern-core/src/runtime/forward.rs +++ b/crates/rustern-core/src/runtime/forward.rs @@ -110,6 +110,10 @@ impl RunStats { self.mux_dropped_lines.fetch_add(1); } + pub fn mux_dropped_line_count(&self) -> u64 { + self.mux_dropped_lines.load() + } + pub fn snapshot_and_reset(&self) -> RunStatsSnapshot { RunStatsSnapshot { active_streams: self.active_streams.load(), @@ -195,13 +199,18 @@ impl MuxMetrics { } pub fn mux_drop_count(&self) -> u64 { - self.mux_dropped.load(Ordering::Relaxed) + if let Some(stats) = &self.stats { + stats.mux_dropped_line_count() + } else { + self.mux_dropped.load(Ordering::Relaxed) + } } pub fn record_mux_drop(&self) { - self.mux_dropped.fetch_add(1, Ordering::Relaxed); if let Some(stats) = &self.stats { stats.record_mux_dropped_line(); + } else { + self.mux_dropped.fetch_add(1, Ordering::Relaxed); } } }