Skip to content

Commit 42fa46b

Browse files
committed
Skip reading counters and gauges with NaN value.
Signed-off-by: Caleb Metz <[email protected]>
1 parent 37f86aa commit 42fa46b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lading/src/target_metrics/prometheus.rs

+10
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ pub(crate) async fn scrape_metrics(
276276
}
277277
};
278278

279+
if value.is_nan() {
280+
warn!("Skipping NaN guage value");
281+
continue;
282+
}
283+
279284
gauge!(format!("target/{name}"), &all_labels.unwrap_or_default()).set(value);
280285
}
281286
Some(MetricType::Counter) => {
@@ -287,6 +292,11 @@ pub(crate) async fn scrape_metrics(
287292
}
288293
};
289294

295+
if value.is_nan() {
296+
warn!("Skipping NaN counter value");
297+
continue;
298+
}
299+
290300
let value = if value < 0.0 {
291301
warn!("Negative counter value unhandled");
292302
continue;

0 commit comments

Comments
 (0)