diff --git a/Cargo.lock b/Cargo.lock index 736691f..ea0bc58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -301,7 +301,6 @@ dependencies = [ "dotenv", "futures-util", "http-signature-normalization-actix", - "indexmap", "lru", "metrics", "metrics-util", diff --git a/Cargo.toml b/Cargo.toml index df7bff6..b753c1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,6 @@ console-subscriber = { version = "0.1", optional = true } dashmap = "5.1.0" dotenv = "0.15.0" futures-util = "0.3.17" -indexmap = "1.9.2" lru = "0.8.0" metrics = "0.20.1" metrics-util = "0.14.0" diff --git a/src/collector.rs b/src/collector.rs index 487713f..0d3536d 100644 --- a/src/collector.rs +++ b/src/collector.rs @@ -1,4 +1,3 @@ -use indexmap::IndexMap; use metrics::{Key, Recorder, SetRecorderError}; use metrics_util::{ registry::{AtomicStorage, GenerationalStorage, Recency, Registry}, @@ -16,6 +15,8 @@ const MINUTES: u64 = 60 * SECONDS; const HOURS: u64 = 60 * MINUTES; const DAYS: u64 = 24 * HOURS; +type DistributionMap = BTreeMap, Summary>; + #[derive(Clone)] pub struct MemoryCollector { inner: Arc, @@ -23,7 +24,7 @@ pub struct MemoryCollector { struct Inner { descriptions: RwLock>, - distributions: RwLock, Summary>>>, + distributions: RwLock>, recency: Recency, registry: Registry>, } @@ -289,7 +290,7 @@ impl Inner { } let mut d = self.distributions.write().unwrap(); - let outer_entry = d.entry(name.clone()).or_insert_with(IndexMap::new); + let outer_entry = d.entry(name.clone()).or_insert_with(BTreeMap::new); let entry = outer_entry .entry(labels) @@ -303,8 +304,7 @@ impl Inner { } let d = self.distributions.read().unwrap().clone(); - let h = d - .into_iter() + d.into_iter() .map(|(key, value)| { ( key, @@ -320,9 +320,7 @@ impl Inner { .collect(), ) }) - .collect(); - - h + .collect() } fn snapshot(&self) -> Snapshot {