From a9cbec9c5791f0e9f9d73f8339a8bbcc5dfd420f Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Wed, 6 Mar 2024 07:16:33 -0500 Subject: [PATCH] fixes --- limitador-server/src/metrics.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/limitador-server/src/metrics.rs b/limitador-server/src/metrics.rs index 7ffa3ee9..d7d3d02b 100644 --- a/limitador-server/src/metrics.rs +++ b/limitador-server/src/metrics.rs @@ -7,7 +7,7 @@ use tracing_subscriber::layer::{Context, Layer}; use tracing_subscriber::registry::LookupSpan; #[derive(Debug, Clone, Copy)] -struct Timings { +pub struct Timings { idle: u64, busy: u64, last: Instant, @@ -66,14 +66,14 @@ impl SpanState { } pub struct MetricsGroup { - consumer: Box, + consumer: fn(Timings), records: Vec, } impl MetricsGroup { pub fn new(consumer: fn(Timings), records: Vec) -> Self { Self { - consumer: Box::new(consumer), + consumer, records, } } @@ -158,7 +158,7 @@ where if let Some(span_state) = extensions.get_mut::() { // either we are an aggregator or nested within one for group in span_state.group_times.keys() { - for record in self.groups.get(group).unwrap().records { + for record in &self.groups.get(group).unwrap().records { if name == record { extensions.insert(Timings::new()); return; @@ -207,7 +207,7 @@ where if let Some(span_state) = extensions.get_mut::() { let group_times = span_state.group_times.clone(); 'aggregate: for group in group_times.keys() { - for record in self.groups.get(group).unwrap().records { + for record in &self.groups.get(group).unwrap().records { if name == record { span_state.increment(group.to_string(), t); continue 'aggregate;