ehcache / ehcache3

Ehcache 3.x line
http://www.ehcache.org
Apache License 2.0
2.01k stars 579 forks source link

how to expose EHCache Mbean statistics to datadog from springboot application? #3182

Open ebett opened 1 year ago

ebett commented 1 year ago

I have a springboot application that runs with datadog agent lib. We can see all app metrics but wanted to see cache statistics in datadog.

I'm using EH-cache 3, I enabled statistics like this example:

 @Bean
  public javax.cache.CacheManager ehCacheManager() {

CacheConfiguration<String, String> myCacheConfig = CacheConfigurationBuilder
        .newCacheConfigurationBuilder(String.class, String.class, ResourcePoolsBuilder.heap(10))
        .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofHours(24)))
        .build();

        org.ehcache.config.Configuration configuration = ConfigurationBuilder.newConfigurationBuilder()
        .withCache("myCache", myCacheConfig)
        .build();

    EhcacheCachingProvider provider = (EhcacheCachingProvider) Caching.getCachingProvider(
        "org.ehcache.jsr107.EhcacheCachingProvider");

    javax.cache.CacheManager cacheManager = provider.getCacheManager(
        provider.getDefaultURI(), configuration);

    cacheManager.enableStatistics("myCache", true);
    return cacheManager;
  }

I see statistics metrics from jconsole localy.

Now I need to expose statistics jmx metrics to DataDog. Do I need to add some specific bean? @ljacomet @chrisdennis