Skip to content

Commit

Permalink
deps: update metriken (iopsystems#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
mihirn authored Apr 2, 2024
1 parent 0257993 commit 2f28a3b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
26 changes: 18 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ clap = "4.4.6"
foreign-types-shared = "0.3.1"
futures = "0.3.28"
http-body-util = "0.1.0-rc.3"
histogram = "0.10.0"
humantime = "2.1.0"
hyper = { version = "1.0.0-rc.4", features = ["http1", "http2", "client"]}
metriken = "0.5.1"
metriken-exposition = { version = "0.4.0", features = ["json", "parquet-conversion"] }
metriken = "0.6.0"
metriken-exposition = { version = "0.5.0", features = ["json", "parquet-conversion"] }
mio = "0.8.8"
momento = "0.32.1"
pelikan-net = "0.1.0"
Expand Down
30 changes: 16 additions & 14 deletions src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl MetricsSnapshot {
}

pub struct HistogramsSnapshot {
pub previous: HashMap<String, metriken::histogram::Snapshot>,
pub deltas: HashMap<String, metriken::histogram::Snapshot>,
pub previous: HashMap<String, histogram::Histogram>,
pub deltas: HashMap<String, histogram::Histogram>,
}

impl Default for HistogramsSnapshot {
Expand All @@ -97,10 +97,11 @@ impl HistogramsSnapshot {
continue;
};

if let Some(histogram) = any.downcast_ref::<metriken::AtomicHistogram>() {
if let Some(snapshot) = histogram.snapshot() {
current.insert(metric.name().to_string(), snapshot);
}
if let Some(histogram) = any
.downcast_ref::<metriken::AtomicHistogram>()
.and_then(|h| h.load())
{
current.insert(metric.name().to_string(), histogram);
}
}

Expand All @@ -120,17 +121,18 @@ impl HistogramsSnapshot {
continue;
};

if let Some(histogram) = any.downcast_ref::<metriken::AtomicHistogram>() {
if let Some(histogram) = any
.downcast_ref::<metriken::AtomicHistogram>()
.and_then(|h| h.load())
{
let metric = metric.name().to_string();

if let Some(snapshot) = histogram.snapshot() {
if let Some(previous) = self.previous.get(&metric) {
self.deltas
.insert(metric.clone(), snapshot.wrapping_sub(previous).unwrap());
}

self.previous.insert(metric, snapshot);
if let Some(previous) = self.previous.get(&metric) {
self.deltas
.insert(metric.clone(), histogram.wrapping_sub(previous).unwrap());
}

self.previous.insert(metric, histogram);
}
}
}
Expand Down

0 comments on commit 2f28a3b

Please sign in to comment.