Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsnaps committed Mar 6, 2024
1 parent 552c8de commit a9cbec9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions limitador-server/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -66,14 +66,14 @@ impl SpanState {
}

pub struct MetricsGroup {
consumer: Box<dyn FnOnce(Timings)>,
consumer: fn(Timings),
records: Vec<String>,
}

Check warning on line 72 in limitador-server/src/metrics.rs

View workflow job for this annotation

GitHub Actions / Rustfmt

Diff in /home/runner/work/limitador/limitador/limitador-server/src/metrics.rs
impl MetricsGroup {
pub fn new(consumer: fn(Timings), records: Vec<String>) -> Self {
Self {
consumer: Box::new(consumer),
consumer,
records,
}
}
Expand Down Expand Up @@ -158,7 +158,7 @@ where
if let Some(span_state) = extensions.get_mut::<SpanState>() {
// 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;
Expand Down Expand Up @@ -207,7 +207,7 @@ where
if let Some(span_state) = extensions.get_mut::<SpanState>() {
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;
Expand Down

0 comments on commit a9cbec9

Please sign in to comment.