I am trying to generate Prometheus metrics with using Micrometer.io with Spring Boot 2.0.0.RELEASE.
When I am trying to expose the size of a List as Gauge, it ke
I had the same issue with Micrometer.io gauges when I used your method #1 meterRegistry.gauge("myGauge", new AtomicDouble())
. I am using Scala by the way. I noticed that after I created about 50 gauges, the new gauges after that displayed NaN
.
Instead I used:
val atomicDouble = new AtomicDouble()
Gauge
.builder("myGauge", atomicDouble, new AtomicDoubleToDoubleFunction)
.strongReference(true)
.register(meterRegistry)
with
class AtomicDoubleToDoubleFunction extends ToDoubleFunction[AtomicDouble] {
override def applyAsDouble(value: AtomicDouble): Double = value.doubleValue()
}
This fixed the NaN
issue, and all of my gauges appear correctly. I found the .strongReference(true)
example from https://www.codota.com/code/java/classes/io.micrometer.core.instrument.Gauge .