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.CacheMeterBinder
Micrometer 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 newCache2kCacheMetrics
instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
bindImplementationSpecificMetrics(io.micrometer.core.instrument.MeterRegistry registry)
Returns additional metrics similar to Caffeine and Guava.protected Long
evictionCount()
Sum up everything which removes an entry no matter the cause.protected long
hitCount()
protected Long
missCount()
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 long
putCount()
protected Long
size()
-
-
-
Constructor Detail
-
Cache2kCacheMetrics
public Cache2kCacheMetrics(org.cache2k.Cache<?,?> cache, Iterable<io.micrometer.core.instrument.Tag> tags)
Creates a newCache2kCacheMetrics
instance.- 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:
size
in classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
hitCount
protected long hitCount()
- Specified by:
hitCount
in classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
missCount
protected Long missCount()
- Specified by:
missCount
in 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:
evictionCount
in classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
putCount
protected long putCount()
- Specified by:
putCount
in 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:
bindImplementationSpecificMetrics
in classio.micrometer.core.instrument.binder.cache.CacheMeterBinder
-
-