I am migrating to Spring Boot 2.0 and I am having issues with my Prometheus Metrics.
I know that MicroMeter is the new way of doing stuff, which is not as crisp as the Prometheus libs but OK.
My issue is that If I do not want to change my metrics now I cannot upgrade to Spring Boot 2.0. Am I right?
I tried the following:
Trial no 1
io.micrometer:micrometer-registry-prometheus:1.0.2
to my app (actuator is already in there)application.properties
to get access to the endpoint actuator/prometheus
=> My Counters
and Gauges
from the past got ignored. OK I understand that from a technical point of view.
Trial no 2
application.properties
to get access to the endpoint actuator/prometheus
=> Now I get the following excpetion
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.actuate.endpoint.AbstractEndpoint
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_161]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_161]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_161]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_161]
... 37 common frames omitted
So my question is: Is there a "soft migration" way which works?
To make Trial no 1 work, just add in the Prometheus default registry as a bean that Micrometer will be able to leverage.
@Bean
public CollectorRegistry collectorRegistry() {
return CollectorRegistry.defaultRegistry;
}
Micrometer doesn't use the default registry by default since it doesn't allow un-registering of meters and can make unit testing quite difficult.
To make Trial no 2 work will require re-implementing the prometheus actuator endpoint, since that class changed drastically with SpringBoot 2. I wouldn't recommend that approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With