Skip to content

Commit 73a06a7

Browse files
committed
Skip gauge metric when callback returns NULL
1 parent 432ef4d commit 73a06a7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/main/java/org/apache/zookeeper/metrics/prometheus/PrometheusMetricsProvider.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,9 @@ public void registerGauge(String name, Gauge gauge) {
385385

386386
GaugeWithCallback newGauge = GaugeWithCallback.builder().name(name).help(name).callback(callback -> {
387387
Number value = gauge.get();
388-
if (value == null) {
389-
throw new IllegalArgumentException("Gauge " + name + " cannot return a null value.");
388+
if (value != null) {
389+
callback.call(value.doubleValue());
390390
}
391-
callback.call(value.doubleValue());
392391
}).register(registry);
393392
registeredGauges.put(name, newGauge);
394393
}

0 commit comments

Comments
 (0)