Skip to content

Implements automatic metrics registration with Micrometer through Spring Actuator

Choose a tag to compare

@stepio stepio released this 13 Jan 23:26

Implemented automatic metrics registration for created caches.
This requires next dependencies:

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-core</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-actuator-autoconfigure</artifactId>
</dependency>

As a side-effect, now project-specific CacheManager is created alongside with the built-in Spring Boot CacheManager and marked as @Primary. This minor overhead allows executing the whole Spring Boot mechanism of cache initialization, including creation of CacheMetricsRegistrar bean.
Individual configurations cannot be invoked as they're package-private. Project-specific deep custom configuration is avoid at all costs to simplify support of newer versions of Spring and Spring Boot.