Package org.cache2k.extra.micrometer
Class Cache2kCacheMetrics
- java.lang.Object
-
- io.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
- org.cache2k.extra.micrometer.Cache2kCacheMetrics
-
- All Implemented Interfaces:
io.micrometer.core.instrument.binder.MeterBinder
public class Cache2kCacheMetrics extends io.micrometer.core.instrument.binder.cache.CacheMeterBinderMicrometer support for cache2k. Metrics will be bound automatically upon cache creation if enabled by the configuration. Alternatively, metrics can be bound to a registry programmatically viamonitor(MeterRegistry, Cache, String...).- Author:
- Jens Wilke
-
-
Constructor Summary
Constructors Constructor Description Cache2kCacheMetrics(org.cache2k.Cache<?,?> cache, Iterable<io.micrometer.core.instrument.Tag> tags)Creates a newCache2kCacheMetricsinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbindImplementationSpecificMetrics(io.micrometer.core.instrument.MeterRegistry registry)Returns additional metrics similar to Caffeine and Guava.protected LongevictionCount()Sum up everything which removes an entry no matter the cause.protected longhitCount()protected LongmissCount()static <C extends org.cache2k.Cache>
Cmonitor(io.micrometer.core.instrument.MeterRegistry registry, C cache, Iterable<io.micrometer.core.instrument.Tag> tags)Record metrics for a cache2k cache.static <C extends org.cache2k.Cache>
Cmonitor(io.micrometer.core.instrument.MeterRegistry registry, C cache, String... tags)Record metrics for a cache2k cache.protected longputCount()protected Longsize()
-
-
-
Constructor Detail
-
Cache2kCacheMetrics
public Cache2kCacheMetrics(org.cache2k.Cache<?,?> cache, Iterable<io.micrometer.core.instrument.Tag> tags)Creates a newCache2kCacheMetricsinstance.- Parameters:
cache- The cache to be instrumented.tags- tags to apply to all recorded metrics.
-
-
Method Detail
-
monitor
public static <C extends org.cache2k.Cache> C monitor(io.micrometer.core.instrument.MeterRegistry registry, C cache, String... tags)Record metrics for a cache2k cache.- Type Parameters:
C- The cache type.- Parameters:
registry- The registry to bind metrics to.cache- The cache to instrument.tags- Tags to apply to all recorded metrics. Must be an even number of arguments representing key/value pairs of tags.- Returns:
- the cache as passed in.
-
monitor
public static <C extends org.cache2k.Cache> C monitor(io.micrometer.core.instrument.MeterRegistry registry, C cache, Iterable<io.micrometer.core.instrument.Tag> tags)Record metrics for a cache2k cache.- Type Parameters:
C- The cache type.- Parameters:
registry- The registry to bind metrics to.cache- The cache to instrument.tags- Tags to apply to all recorded metrics.- Returns:
- the cache as passed in.
-
size
protected Long 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
protected Long missCount()
- Specified by:
missCountin classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
evictionCount
protected Long evictionCount()
Sum up everything which removes an entry no matter the cause. This is probably most similar to the behavior of other caches.TODO: have separate metric for expired entries
- 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)
Returns additional metrics similar to Caffeine and Guava.TODO: loads/refresh, evicted/expired
- Specified by:
bindImplementationSpecificMetricsin classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
-