Class EhcacheCacheMetrics
java.lang.Object
io.micrometer.core.instrument.binder.cache.CacheMeterBinder
com.broadleafcommerce.common.extension.cache.ehcache.EhcacheCacheMetrics
- All Implemented Interfaces:
io.micrometer.core.instrument.binder.MeterBinder
public class EhcacheCacheMetrics
extends io.micrometer.core.instrument.binder.cache.CacheMeterBinder
A helper class for monitoring and exposing Ehcache 3 cache metrics through Micrometer.
This implementation utilizes a background thread to refresh the cache statistics (e.g., hit/miss counts, size, and offheap weight) upon a scrape request. By offloading these calculations we prevent blocking the main request threads during Micrometer scrapes.
If a refresh is already in progress, additional scrape requests will use the currently available metrics and will not spawn additional tasks.
This binder exposes cache.offheap.used and cache.offheap.bytes gauges to
accurately report the total off-heap memory footprint of the cache region.
-
Constructor Summary
ConstructorsConstructorDescriptionEhcacheCacheMetrics(ExecutorService refreshExecutor, javax.cache.Cache<?, ?> cache, String name, Iterable<io.micrometer.core.instrument.Tag> tags) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbindImplementationSpecificMetrics(io.micrometer.core.instrument.MeterRegistry registry) protected Longprotected longhitCount()protected Longstatic EhcacheCacheMetricsmonitor(io.micrometer.core.instrument.MeterRegistry registry, ExecutorService refreshExecutor, javax.cache.Cache<?, ?> cache, String name, String... tags) protected longputCount()protected Longsize()Methods inherited from class io.micrometer.core.instrument.binder.cache.CacheMeterBinder
bindTo, getCache, getTagsWithCacheName
-
Constructor Details
-
EhcacheCacheMetrics
public EhcacheCacheMetrics(ExecutorService refreshExecutor, javax.cache.Cache<?, ?> cache, String name, Iterable<io.micrometer.core.instrument.Tag> tags)
-
-
Method Details
-
monitor
public static EhcacheCacheMetrics monitor(io.micrometer.core.instrument.MeterRegistry registry, ExecutorService refreshExecutor, javax.cache.Cache<?, ?> cache, String name, String... tags) -
size
- Specified by:
sizein classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
hitCount
protected long hitCount()- Specified by:
hitCountin classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
missCount
- Specified by:
missCountin classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
evictionCount
- Specified by:
evictionCountin classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
putCount
protected long putCount()- Specified by:
putCountin classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
bindImplementationSpecificMetrics
protected void bindImplementationSpecificMetrics(io.micrometer.core.instrument.MeterRegistry registry) - Specified by:
bindImplementationSpecificMetricsin classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-