I am annotating a public method (non-controller) with @Timed and I can see that it is created in PrometheusMeterRegistry and appears in /actuator/metrics — after being called at least once.
Setting a breakpoint at PrometheusMeterRegistry::newTimer does show that the metric is being created in a huge TimedAspect call stack. I have management.observations.annotations.enabled=true set.
However the endpoint /actuator/prometheus depends on a PrometheusRegistry field (and PrometheusMeterRegistry shares the same object as a field registry). However this field doen't seem to get updated during newTimer so /actuator/prometheus doesn't change.
When scraping /actuator/prometheus the new Timer does not appear.
OTOH in JMX, I do see the new Timer created with a very long name (it includes the class, exception, and extraTags).
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-jmx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
management.endpoints.jmx.exposure.include=health,info,env,beans,caches,prometheus,metrics
management.endpoints.web.exposure.include=health,info,env,beans,caches,prometheus,metrics
management.prometheus.metrics.export.enabled=true
management.jmx.metrics.export.enabled=true
management.observations.annotations.enabled=true
spring.jmx.enabled=true
Comment From: mhalbritter
Hey, thanks for the report. If you'd like us to spend some time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.
Comment From: space88man
Update: the name had been used in a different method with a different set of tags; I see that the Prometheus registry doesn't allow this. Sorry for the noise.
Comment From: mhalbritter
No harm done, thanks for chiming back in.