@NonNullApi
@NonNullFields
public class MicronautCaffeineCacheMetrics
extends io.micrometer.core.instrument.binder.cache.CacheMeterBinder
Note that `recordStats()` is required to gather non-zero statistics:
Cache<String, String> cache = Caffeine.newBuilder().recordStats().build();
CaffeineCacheMetrics.monitor(registry, cache, "mycache", "region", "test");
NOTE: This is a fork of https://github.com/micrometer-metrics/micrometer/blob/master/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/cache/CaffeineCacheMetrics.java The reason for the fork is because Micronaut repackages caffeine under a different package
Constructor and Description |
---|
MicronautCaffeineCacheMetrics(io.micronaut.caffeine.cache.Cache<?,?> cache,
java.lang.String cacheName,
java.lang.Iterable<io.micrometer.core.instrument.Tag> tags)
Creates a new
MicronautCaffeineCacheMetrics instance. |
Modifier and Type | Method and Description |
---|---|
protected void |
bindImplementationSpecificMetrics(io.micrometer.core.instrument.MeterRegistry registry) |
protected java.lang.Long |
evictionCount() |
protected long |
hitCount() |
protected java.lang.Long |
missCount() |
static <C extends io.micronaut.caffeine.cache.AsyncLoadingCache> |
monitor(io.micrometer.core.instrument.MeterRegistry registry,
C cache,
java.lang.String cacheName,
java.lang.Iterable<io.micrometer.core.instrument.Tag> tags)
Record metrics on a Caffeine cache.
|
static <C extends io.micronaut.caffeine.cache.Cache> |
monitor(io.micrometer.core.instrument.MeterRegistry registry,
C cache,
java.lang.String cacheName,
java.lang.Iterable<io.micrometer.core.instrument.Tag> tags)
Record metrics on a Caffeine cache.
|
static <C extends io.micronaut.caffeine.cache.AsyncLoadingCache> |
monitor(io.micrometer.core.instrument.MeterRegistry registry,
C cache,
java.lang.String cacheName,
java.lang.String... tags)
Record metrics on a Caffeine cache.
|
static <C extends io.micronaut.caffeine.cache.Cache> |
monitor(io.micrometer.core.instrument.MeterRegistry registry,
C cache,
java.lang.String cacheName,
java.lang.String... tags)
Record metrics on a Caffeine cache.
|
protected long |
putCount() |
protected java.lang.Long |
size() |
public MicronautCaffeineCacheMetrics(io.micronaut.caffeine.cache.Cache<?,?> cache, java.lang.String cacheName, java.lang.Iterable<io.micrometer.core.instrument.Tag> tags)
MicronautCaffeineCacheMetrics
instance.cache
- The cache to be instrumented. You must call Caffeine
prior to building the cache
for metrics to be recorded.cacheName
- Will be used to tag metrics with "cache".tags
- tags to apply to all recorded metrics.public static <C extends io.micronaut.caffeine.cache.Cache> C monitor(io.micrometer.core.instrument.MeterRegistry registry, C cache, java.lang.String cacheName, java.lang.String... tags)
Caffeine.recordStats()
prior to building the cache
for metrics to be recorded.C
- The cache type.registry
- The registry to bind metrics to.cache
- The cache to instrument.cacheName
- Will be used to tag metrics with "cache".tags
- Tags to apply to all recorded metrics. Must be an even number of arguments representing key/value pairs of tags.public static <C extends io.micronaut.caffeine.cache.Cache> C monitor(io.micrometer.core.instrument.MeterRegistry registry, C cache, java.lang.String cacheName, java.lang.Iterable<io.micrometer.core.instrument.Tag> tags)
Caffeine.recordStats()
prior to building the cache
for metrics to be recorded.C
- The cache type.registry
- The registry to bind metrics to.cache
- The cache to instrument.cacheName
- Will be used to tag metrics with "cache".tags
- Tags to apply to all recorded metrics.CacheStats
public static <C extends io.micronaut.caffeine.cache.AsyncLoadingCache> C monitor(io.micrometer.core.instrument.MeterRegistry registry, C cache, java.lang.String cacheName, java.lang.String... tags)
Caffeine.recordStats()
prior to building the cache
for metrics to be recorded.C
- The cache type.registry
- The registry to bind metrics to.cache
- The cache to instrument.cacheName
- Will be used to tag metrics with "cache".tags
- Tags to apply to all recorded metrics. Must be an even number of arguments representing key/value pairs of tags.public static <C extends io.micronaut.caffeine.cache.AsyncLoadingCache> C monitor(io.micrometer.core.instrument.MeterRegistry registry, C cache, java.lang.String cacheName, java.lang.Iterable<io.micrometer.core.instrument.Tag> tags)
Caffeine.recordStats()
prior to building the cache
for metrics to be recorded.C
- The cache type.registry
- The registry to bind metrics to.cache
- The cache to instrument.cacheName
- Will be used to tag metrics with "cache".tags
- Tags to apply to all recorded metrics.CacheStats
protected java.lang.Long size()
size
in class io.micrometer.core.instrument.binder.cache.CacheMeterBinder
protected long hitCount()
hitCount
in class io.micrometer.core.instrument.binder.cache.CacheMeterBinder
protected java.lang.Long missCount()
missCount
in class io.micrometer.core.instrument.binder.cache.CacheMeterBinder
protected java.lang.Long evictionCount()
evictionCount
in class io.micrometer.core.instrument.binder.cache.CacheMeterBinder
protected long putCount()
putCount
in class io.micrometer.core.instrument.binder.cache.CacheMeterBinder
protected void bindImplementationSpecificMetrics(io.micrometer.core.instrument.MeterRegistry registry)
bindImplementationSpecificMetrics
in class io.micrometer.core.instrument.binder.cache.CacheMeterBinder