private void registerStatistic(Object context, String name, String observerName, String tag, String propertyKey, ValueStatistic<Number> source) { Map<String, Object> properties = new HashMap<>(); properties.put("discriminator", tag); properties.put(propertyKey, name); StatisticsManager.createPassThroughStatistic(context, observerName, tags(tag, "tier"), properties, source); }
@Before public void before() { CacheConfiguration<Long, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, heap(10)) .add(new StoreStatisticsConfiguration(true)) // explicitly enable statistics .build(); cacheManager = CacheManagerBuilder.newCacheManagerBuilder() .withCache("aCache", cacheConfiguration) .build(true); cache = cacheManager.getCache("aCache", Long.class, String.class); StatisticsManager.createPassThroughStatistic(cache, "test", tags(), properties("myproperty=myvalue"), StatisticType.COUNTER, () -> 0); cache.get(1L); }
this.installMappingObserver= createObserver("installMapping", LowerCachingTierOperationsOutcome.InstallMappingOutcome.class, true); Set<String> tags = tags(getStatisticsTag(), "tier"); registerStatistic("allocatedMemory", GAUGE, tags, EhcacheOffHeapBackingMap::allocatedMemory); registerStatistic("occupiedMemory", GAUGE, tags, EhcacheOffHeapBackingMap::occupiedMemory);
this.installMappingObserver= createObserver("installMapping", LowerCachingTierOperationsOutcome.InstallMappingOutcome.class, true); Set<String> tags = tags(getStatisticsTag(), "tier"); registerStatistic("allocatedMemory", GAUGE, tags, EhcacheOffHeapBackingMap::allocatedMemory); registerStatistic("occupiedMemory", GAUGE, tags, EhcacheOffHeapBackingMap::occupiedMemory);