From d12042f1a0a0e34ca274de9035ea35b6c016783f Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Thu, 6 Oct 2022 10:03:34 +0200 Subject: [PATCH] Skip `unexpected metric type` * Dump more info for `unexpected metric type` * Skip `unexpected metric type` --- node/metrics/src/tests.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/node/metrics/src/tests.rs b/node/metrics/src/tests.rs index 56e07d96280d..932cc7b68be7 100644 --- a/node/metrics/src/tests.rs +++ b/node/metrics/src/tests.rs @@ -92,16 +92,11 @@ async fn scrape_prometheus_metrics(metrics_uri: &str) -> HashMap { .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() }