use of net.sf.ehcache.statistics.StatisticsGateway in project spring-boot by spring-projects.
the class EhCacheStatisticsProvider method getCacheStatistics.
@Override
public CacheStatistics getCacheStatistics(CacheManager cacheManager, EhCacheCache cache) {
DefaultCacheStatistics statistics = new DefaultCacheStatistics();
StatisticsGateway ehCacheStatistics = cache.getNativeCache().getStatistics();
statistics.setSize(ehCacheStatistics.getSize());
double hitRatio = cacheHitRatio(ehCacheStatistics);
if (!Double.isNaN(hitRatio)) {
// ratio is calculated 'racily' and can drift marginally above unity,
// so we cap it here
double sanitizedHitRatio = (hitRatio > 1 ? 1 : hitRatio);
statistics.setHitRatio(sanitizedHitRatio);
statistics.setMissRatio(1 - sanitizedHitRatio);
}
return statistics;
}
use of net.sf.ehcache.statistics.StatisticsGateway in project micrometer by micrometer-metrics.
the class EhCache2Metrics method rollbackTransactionMetrics.
private void rollbackTransactionMetrics(MeterRegistry registry) {
StatisticsGateway stats = getStats();
FunctionCounter.builder("cache.xa.rollbacks", stats, StatisticsGateway::xaRollbackExceptionCount).tags(getTagsWithCacheName()).tags("result", "exception").description("Transaction rollbacks that failed").register(registry);
FunctionCounter.builder("cache.xa.rollbacks", stats, StatisticsGateway::xaRollbackSuccessCount).tags(getTagsWithCacheName()).tags("result", "success").description("Transaction rollbacks that failed").register(registry);
}
use of net.sf.ehcache.statistics.StatisticsGateway in project micrometer by micrometer-metrics.
the class EhCache2Metrics method recoveryTransactionMetrics.
private void recoveryTransactionMetrics(MeterRegistry registry) {
StatisticsGateway stats = getStats();
FunctionCounter.builder("cache.xa.recoveries", stats, StatisticsGateway::xaRecoveryNothingCount).tags(getTagsWithCacheName()).tags("result", "nothing").description("Recovery transactions that recovered nothing").register(registry);
FunctionCounter.builder("cache.xa.recoveries", stats, StatisticsGateway::xaRecoveryRecoveredCount).tags(getTagsWithCacheName()).tags("result", "success").description("Successful recovery transaction").register(registry);
}
use of net.sf.ehcache.statistics.StatisticsGateway in project micrometer by micrometer-metrics.
the class EhCache2MetricsTest method returnCacheSize.
@Test
void returnCacheSize() {
StatisticsGateway stats = cache.getStatistics();
assertThat(metrics.size()).isEqualTo(stats.getSize());
}
use of net.sf.ehcache.statistics.StatisticsGateway in project micrometer by micrometer-metrics.
the class EhCache2MetricsTest method returnHitCount.
@Test
void returnHitCount() {
StatisticsGateway stats = cache.getStatistics();
assertThat(metrics.hitCount()).isEqualTo(stats.cacheHitCount());
}
Aggregations