See https://github.com/spring-projects/spring-boot/issues/46017 for background.
Micrometer is going to provide a setting that allows the JCache removals to be registered as a function counter. As far as I can tell, that option won't be usable in Boot as the auto-configured JCacheCacheMeterBinderProvider isn't @ConditionalOnMissingBean so there's no easy way to define your own provider with a custom JCacheMetrics that uses a function counter for removals.
A couple of options:
- Make the auto-configured
JCacheCacheMeterBinderProvider@ConditionalOnMissingBean - Provide a configuration property, something like
management.metrics.cache.jcache.register-removals-as-function-counter, to control Micrometer's new setting.
We could do either or both of these.
Comment From: hakimrabet
I've submitted a PR. spring-projects/spring-boot#46355. It makes JCacheCacheMeterBinderProvider overridable and add a configuration to register removals as a function counter. I'm not sure if it's exactly what you're looking for, but i'm happy to adjust it based on feedback.
Comment From: wilkinsona
We don't know what we're looking for at the moment, hence the pending-design-work label. That design work will have to be done by a member of the core team before we can proceed.
Comment From: jonatan-ivanov
fyi: https://github.com/micrometer-metrics/micrometer/pull/6471 is released Also, latest bits of Micrometer should prevent registering different Prometheus types with the same name: https://github.com/micrometer-metrics/micrometer/pull/6470 (scrape should not fail but time series will be missing).
Comment From: wilkinsona
You can now choose to have removals registered as a function counter by defining your own bean:
@Bean
JCacheCacheMeterBinderProvider customMeterBinderProvider() {
return new JCacheCacheMeterBinderProvider(true);
}