From 993f46a81d5ed3597154db11ea0d7f7961aeac4c Mon Sep 17 00:00:00 2001 From: Eric Semeniuc <3838856+esemeniuc@users.noreply.github.com> Date: Mon, 4 Dec 2023 13:10:15 -0800 Subject: [PATCH] update metrics --- core/src/bundle_stage.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/core/src/bundle_stage.rs b/core/src/bundle_stage.rs index d140cb4953..15810cc756 100644 --- a/core/src/bundle_stage.rs +++ b/core/src/bundle_stage.rs @@ -100,24 +100,24 @@ impl BundleStageLoopMetrics { .fetch_add(count, Ordering::Relaxed); } - pub fn increment_current_buffered_bundles_count(&mut self, count: u64) { + pub fn set_current_buffered_bundles_count(&mut self, count: u64) { self.current_buffered_bundles_count - .fetch_add(count, Ordering::Relaxed); + .store(count, Ordering::Relaxed); } - pub fn increment_current_buffered_packets_count(&mut self, count: u64) { + pub fn set_current_buffered_packets_count(&mut self, count: u64) { self.current_buffered_packets_count - .fetch_add(count, Ordering::Relaxed); + .store(count, Ordering::Relaxed); } - pub fn increment_cost_model_buffered_bundles_count(&mut self, count: u64) { + pub fn set_cost_model_buffered_bundles_count(&mut self, count: u64) { self.cost_model_buffered_bundles_count - .fetch_add(count, Ordering::Relaxed); + .store(count, Ordering::Relaxed); } - pub fn increment_cost_model_buffered_packets_count(&mut self, count: u64) { + pub fn set_cost_model_buffered_packets_count(&mut self, count: u64) { self.cost_model_buffered_packets_count - .fetch_add(count, Ordering::Relaxed); + .store(count, Ordering::Relaxed); } pub fn increment_num_bundles_dropped(&mut self, count: u64) { @@ -381,16 +381,14 @@ impl BundleStage { } let bundle_storage = unprocessed_bundle_storage.bundle_storage().unwrap(); - bundle_stage_metrics.increment_current_buffered_bundles_count( - bundle_storage.unprocessed_bundles_len() as u64, - ); - bundle_stage_metrics.increment_current_buffered_packets_count( - bundle_storage.unprocessed_packets_len() as u64, - ); - bundle_stage_metrics.increment_cost_model_buffered_bundles_count( + bundle_stage_metrics + .set_current_buffered_bundles_count(bundle_storage.unprocessed_bundles_len() as u64); + bundle_stage_metrics + .set_current_buffered_packets_count(bundle_storage.unprocessed_packets_len() as u64); + bundle_stage_metrics.set_cost_model_buffered_bundles_count( bundle_storage.cost_model_buffered_bundles_len() as u64, ); - bundle_stage_metrics.increment_cost_model_buffered_packets_count( + bundle_stage_metrics.set_cost_model_buffered_packets_count( bundle_storage.cost_model_buffered_packets_len() as u64, ); bundle_stage_metrics.maybe_report(1_000);