Skip to content

Commit

Permalink
deps: update metriken
Browse files Browse the repository at this point in the history
  • Loading branch information
mihirn committed Apr 3, 2024
1 parent eac580e commit f2af32f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 21 deletions.
38 changes: 30 additions & 8 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ humantime = "2.1.0"
lazy_static = "1.4.0"
libc = "0.2.147"
linkme = "0.3.15"
metriken = "0.5.1"
metriken-exposition = { version = "0.4.0", features = ["serde", "msgpack"] }
metriken = "0.6.0"
metriken-exposition = { version = "0.5.0", features = ["serde", "msgpack"] }
memmap2 = "0.5.10"
num_cpus = "1.16.0"
once_cell = "1.18.0"
Expand All @@ -34,7 +34,7 @@ toml = "0.7.6"
walkdir = "2.3.3"
warp = { version = "0.3.6", features = ["compression"] }
serde_repr = "0.1.18"
histogram = { version = "0.9.0", features = ["serde"] }
histogram = { version = "0.10.0", features = ["serde"] }
chrono = { version = "0.4.33", features = ["serde"] }

[target.'cfg(target_os = "linux")'.dependencies]
Expand Down
19 changes: 9 additions & 10 deletions src/exposition/http.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{Arc, Config, PERCENTILES};
use metriken::histogram::Snapshot;
use metriken::{AtomicHistogram, Counter, Gauge, RwLockHistogram};
use metriken_exposition::SnapshotterBuilder;
use std::time::UNIX_EPOCH;
Expand Down Expand Up @@ -140,23 +139,23 @@ mod handlers {
}
}
if config.prometheus().histograms() {
if let Some(snapshot) = snapshots.previous.get(metric.name()) {
if let Some(histogram) = snapshots.previous.get(metric.name()) {
let current = HISTOGRAM_GROUPING_POWER;
let target = config.prometheus().histogram_grouping_power();

// downsample the snapshot if necessary
let downsampled: Option<Snapshot> = if current == target {
// downsample the histogram if necessary
let downsampled: Option<histogram::Histogram> = if current == target {
// the powers matched, we don't need to downsample
None
} else {
Some(snapshot.value.downsample(target).unwrap())
Some(histogram.value.downsample(target).unwrap())
};

// reassign to either use the downsampled snapshot or the original
let snapshot = if let Some(snapshot) = downsampled.as_ref() {
snapshot
// reassign to either use the downsampled histogram or the original
let histogram = if let Some(histogram) = downsampled.as_ref() {
histogram
} else {
&snapshot.value
&histogram.value
};

// we need to export a total count (free-running)
Expand All @@ -166,7 +165,7 @@ mod handlers {
let mut sum = 0;

let mut entry = format!("# TYPE {name}_distribution histogram\n");
for bucket in snapshot {
for bucket in histogram {
// add this bucket's sum of observations
sum += bucket.count() * bucket.end();

Expand Down

0 comments on commit f2af32f

Please sign in to comment.