Reputation: 457
I am using Scaffeine in my project (https://github.com/blemale/scaffeine), a Scala wrapper for Caffeine (https://github.com/ben-manes/caffeine). I also have a prometheus JMX collector embedded in my metrics API (https://github.com/Segence/kamon-jmx-collector).
However when I launch my application, I can't really see any MBeans
for Caffeine in VisualVM.
Also, when looking at the Caffeine project, I found that in the caffeine/jcache/src/main/resources/reference.conf
there is a config for JMX monitoring:
monitoring {
# If cache statistics should be recorded and externalized
statistics = false
# If the configuration should be externalized
management = false
}
Both are set to false. Is there a way to configure Caffeine so that it exposes MBeans to JMX?
Upvotes: 2
Views: 986
Reputation: 457
Thanks Ben Manes,
This would be the answer according to prometheus:
import io.prometheus.client.cache.caffeine.CacheMetricsCollector
CacheMetricsCollector cacheMetrics = new CacheMetricsCollector().register();
Cache<String, String> cache = Caffeine.newBuilder().recordStats().build();
cacheMetrics.addCache("myCacheLabel", cache);
Upvotes: 2