Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Skip unexpected metric type
Browse files Browse the repository at this point in the history
* Dump more info for `unexpected metric type`

* Skip `unexpected metric type`
  • Loading branch information
bkontur authored Oct 6, 2022
1 parent 3646202 commit d12042f
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions node/metrics/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,11 @@ async fn scrape_prometheus_metrics(metrics_uri: &str) -> HashMap<String, u64> {
.expect("Scraper failed to parse Prometheus metrics")
.samples
.into_iter()
.map(|sample| {
(
sample.metric.to_owned(),
match sample.value {
prometheus_parse::Value::Counter(value) => value as u64,
prometheus_parse::Value::Gauge(value) => value as u64,
prometheus_parse::Value::Untyped(value) => value as u64,
_ => unreachable!("unexpected metric type"),
},
)
.filter_map(|prometheus_parse::Sample { metric, value, .. }| match value {
prometheus_parse::Value::Counter(value) => Some((metric, value as u64)),
prometheus_parse::Value::Gauge(value) => Some((metric, value as u64)),
prometheus_parse::Value::Untyped(value) => Some((metric, value as u64)),
_ => None,
})
.collect()
}

0 comments on commit d12042f

Please sign in to comment.