use of org.springframework.boot.actuate.cache.CacheStatistics in project spring-boot by spring-projects.
the class CachePublicMetrics method addMetrics.
private void addMetrics(Collection<Metric<?>> metrics, String cacheName, List<CacheManagerBean> cacheManagerBeans) {
for (CacheManagerBean cacheManagerBean : cacheManagerBeans) {
CacheManager cacheManager = cacheManagerBean.getCacheManager();
Cache cache = cacheManager.getCache(cacheName);
CacheStatistics statistics = getCacheStatistics(cache, cacheManager);
if (statistics != null) {
String prefix = cacheName;
if (cacheManagerBeans.size() > 1) {
prefix = cacheManagerBean.getBeanName() + "_" + prefix;
}
prefix = "cache." + prefix + (prefix.endsWith(".") ? "" : ".");
metrics.addAll(statistics.toMetrics(prefix));
}
}
}
use of org.springframework.boot.actuate.cache.CacheStatistics in project spring-boot by spring-projects.
the class CacheStatisticsAutoConfigurationTests method doTestCoreStatistics.
private void doTestCoreStatistics(CacheStatisticsProvider provider, boolean supportSize) {
Cache books = getCache("books");
CacheStatistics cacheStatistics = provider.getCacheStatistics(this.cacheManager, books);
assertCoreStatistics(cacheStatistics, (supportSize ? 0L : null), null, null);
getOrCreate(books, "a", "b", "b", "a", "a", "a");
CacheStatistics updatedCacheStatistics = provider.getCacheStatistics(this.cacheManager, books);
assertCoreStatistics(updatedCacheStatistics, (supportSize ? 2L : null), 0.66D, 0.33D);
}
use of org.springframework.boot.actuate.cache.CacheStatistics in project spring-boot by spring-projects.
the class CacheStatisticsAutoConfigurationTests method noOpCacheStatistics.
@Test
public void noOpCacheStatistics() {
load(NoOpCacheConfig.class);
CacheStatisticsProvider provider = this.context.getBean("noOpCacheStatisticsProvider", CacheStatisticsProvider.class);
Cache books = getCache("books");
CacheStatistics cacheStatistics = provider.getCacheStatistics(this.cacheManager, books);
assertCoreStatistics(cacheStatistics, null, null, null);
getOrCreate(books, "a", "b", "b", "a", "a");
CacheStatistics updatedCacheStatistics = provider.getCacheStatistics(this.cacheManager, books);
assertCoreStatistics(updatedCacheStatistics, null, null, null);
}
use of org.springframework.boot.actuate.cache.CacheStatistics in project spring-boot by spring-projects.
the class CacheStatisticsAutoConfigurationTests method concurrentMapCacheStatistics.
@Test
public void concurrentMapCacheStatistics() {
load(ConcurrentMapConfig.class);
CacheStatisticsProvider provider = this.context.getBean("concurrentMapCacheStatisticsProvider", CacheStatisticsProvider.class);
Cache books = getCache("books");
CacheStatistics cacheStatistics = provider.getCacheStatistics(this.cacheManager, books);
assertCoreStatistics(cacheStatistics, 0L, null, null);
getOrCreate(books, "a", "b", "b", "a", "a");
CacheStatistics updatedCacheStatistics = provider.getCacheStatistics(this.cacheManager, books);
assertCoreStatistics(updatedCacheStatistics, 2L, null, null);
}
Aggregations