You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like the current implementation of the io.prometheus.metrics.core.metrics.StatefulMetric#clear method (see #935) is clearing the data, but not nullifying the io.prometheus.metrics.core.metrics.StatefulMetric#noLabels field, allowing that to be returned by the io.prometheus.metrics.core.metrics.StatefulMetric#getNoLabels method, but preventing it from being correctly collected.
This is easily reproducible in the io.prometheus.metrics.core.metrics.StatefulMetricTest#testClearNoLabels test by adding an inc() call and verification after the first clear:
...
counter.clear();
// No labels is always present, but as no value has been observed after clear() the value should be 0.0
Assert.assertEquals(1, counter.collect().getDataPoints().size());
Assert.assertEquals(0.0, counter.collect().getDataPoints().get(0).getValue(), 0.0);
// Now we're testing label-less inc() still works correctly
counter.inc();
Assert.assertEquals(1, counter.collect().getDataPoints().size());
Assert.assertEquals(1.0, counter.collect().getDataPoints().get(0).getValue(), 0.0);
If my understanding of the issue is correct, the io.prometheus.metrics.core.metrics.StatefulMetric#clear should also set noLabels = null.
The text was updated successfully, but these errors were encountered:
It looks like the current implementation of the
io.prometheus.metrics.core.metrics.StatefulMetric#clear
method (see #935) is clearing the data, but not nullifying theio.prometheus.metrics.core.metrics.StatefulMetric#noLabels
field, allowing that to be returned by theio.prometheus.metrics.core.metrics.StatefulMetric#getNoLabels
method, but preventing it from being correctly collected.This is easily reproducible in the
io.prometheus.metrics.core.metrics.StatefulMetricTest#testClearNoLabels
test by adding aninc()
call and verification after the first clear:If my understanding of the issue is correct, the
io.prometheus.metrics.core.metrics.StatefulMetric#clear
should also setnoLabels = null
.The text was updated successfully, but these errors were encountered: