Starting and stopping Spring Boot metrics on demand

Viewed 92

Spring Boot 2.x here. Reading through metrics/micrometer docs and trying to figure out how I could stop/restart all metrics collections on the fly at runtime.

It looks like the typical way metrics registries are created are:

SimpleMeterRegistry registry = new SimpleMeterRegistry();

And I would expect this to happen in a @Bean-annotated method from inside a @Configuration-annotated class. So to me, this indicates that the registry is started automatically as part of some background process. However, for my application, I want to be able to explicitly start/stop/restart metrics collection on demand.

Any ideas as to how to accomplish this? Thanks in advance.

0 Answers
Related