I upgraded my project’s Maven dependencies to Spring Boot 3, so I needed to upgrade Prometheus and Micrometer to version 1.10 or higher as well.
When all these were done, my Spring Boot application started successfully, but when I accessed /actuator/prometheus, I got the following error:
caused: class io.prometheus.metrics.model.snapshots.SummarySnapshot$SummaryDataPointSnapshot cannot be cast to class io.prometheus.metrics.model.snapshots.GaugeSnapshot$GaugeDataPointSnapshot (io.prometheus.metrics.model.snapshots.SummarySnapshot$SummaryDataPointSnapshot and io.prometheus.metrics.model.snapshots.GaugeSnapshot$GaugeDataPointSnapshot are in unnamed module of loader 'app');
By the way, my actuator and security are both the latest versions. Some related maven denpendencies are here:
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>
I tried to migrate my code following the official guides like below:
- https://github.com/micrometer-metrics/micrometer/wiki/Migrating-to-new-1.10.0-Observation-API
- https://github.com/spring-projects/spring-boot/issues/40907
- https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#micrometer-and-metrics-changes
However, I don’t have the same problems mentioned in these guides. And there are no usages of SummarySnapshot and GaugeSnapshot in my code. Why did this error happen?
TL;DR
Please remove the io.prometheus:simpleclient
dependency, + upgrade to latest Spring Boot and the error should go away (assuming you use micrometer-registry-prometheus
), if this does not help, please see below.
Details
Please check the 1.13.0
release notes:
Please take a look at the Migration Guide if you use Prometheus since there are breaking changes in the Prometheus registry if you are using the PrometheusMeterRegistry API in your code.
In Micrometer 1.13.0
we migrated from Prometheus 0.x
to 1.x
but you can go back to the old version of Prometheus if you don’t want to migrate right now:
The micrometer-registry-prometheus
module has upgraded to the Prometheus Java client 1.x version, which required some breaking changes from the prior 0.x version. The breaking changes may not affect all users depending on whether you are directly interacting with the API in PrometheusMeterRegistry
or a framework is handling that configuration for you. As a fallback to ease upgrading, the previous code based on the Prometheus Java client 0.x is available in a new module named micrometer-registry-prometheus-simpleclient
(deprecated). The plan is to eventually remove support for the micrometer-registry-prometheus-simpleclient
so it should only be used as an interim solution until you can adapt to the necessary changes in micrometer-registry-prometheus
related to the upgrade to Prometheus Java client 1.x.
If you want to migrate to the Prometheus Java client 1.x with Micrometer 1.13.0:
- runtimeOnly 'io.micrometer:micrometer-registry-prometheus:1.12.+'
+ runtimeOnly 'io.micrometer:micrometer-registry-prometheus:1.13.+'
If you want to stay on the Prometheus Java client 0.x but you want to migrate to Micrometer 1.13.0:
- runtimeOnly 'io.micrometer:micrometer-registry-prometheus:1.12.+'
+ runtimeOnly 'io.micrometer:micrometer-registry-prometheus-simpleclient:1.13.+'
1