2

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?

4

1 回答 1

2

谢谢本·马内斯,

根据普罗米修斯,这将是答案:

import io.prometheus.client.cache.caffeine.CacheMetricsCollector

CacheMetricsCollector cacheMetrics = new CacheMetricsCollector().register();

Cache<String, String> cache = Caffeine.newBuilder().recordStats().build();
cacheMetrics.addCache("myCacheLabel", cache);

于 2019-11-19T16:19:54.097 回答