@NonNullApi @NonNullFields public class CaffeineCacheMetrics extends java.lang.Object implements MeterBinder
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");
| Constructor and Description |
|---|
CaffeineCacheMetrics(com.github.benmanes.caffeine.cache.Cache<?,?> cache,
java.lang.String name,
java.lang.Iterable<Tag> tags)
Creates a new
CaffeineCacheMetrics instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
bindTo(MeterRegistry registry) |
static <C extends com.github.benmanes.caffeine.cache.AsyncLoadingCache> |
monitor(MeterRegistry registry,
C cache,
java.lang.String name,
java.lang.Iterable<Tag> tags)
Record metrics on a Caffeine cache.
|
static <C extends com.github.benmanes.caffeine.cache.Cache> |
monitor(MeterRegistry registry,
C cache,
java.lang.String name,
java.lang.Iterable<Tag> tags)
Record metrics on a Caffeine cache.
|
static <C extends com.github.benmanes.caffeine.cache.AsyncLoadingCache> |
monitor(MeterRegistry registry,
C cache,
java.lang.String name,
java.lang.String... tags)
Record metrics on a Caffeine cache.
|
static <C extends com.github.benmanes.caffeine.cache.Cache> |
monitor(MeterRegistry registry,
C cache,
java.lang.String name,
java.lang.String... tags)
Record metrics on a Caffeine cache.
|
public CaffeineCacheMetrics(com.github.benmanes.caffeine.cache.Cache<?,?> cache,
java.lang.String name,
java.lang.Iterable<Tag> tags)
CaffeineCacheMetrics instance.cache - The cache to be instrumented. You must call Caffeine.recordStats() prior to building the cache
for metrics to be recorded.name - The metric name prefixtags - tags to apply to all recorded metricspublic static <C extends com.github.benmanes.caffeine.cache.Cache> C monitor(MeterRegistry registry, C cache, java.lang.String name, java.lang.String... tags)
Caffeine.recordStats() prior to building the cache
for metrics to be recorded.registry - The registry to bind metrics to.cache - The cache to instrument.name - The name prefix of the metrics.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 com.github.benmanes.caffeine.cache.Cache> C monitor(MeterRegistry registry, C cache, java.lang.String name, java.lang.Iterable<Tag> tags)
Caffeine.recordStats() prior to building the cache
for metrics to be recorded.registry - The registry to bind metrics to.cache - The cache to instrument.name - The name prefix of the metrics.tags - Tags to apply to all recorded metrics.CacheStatspublic static <C extends com.github.benmanes.caffeine.cache.AsyncLoadingCache> C monitor(MeterRegistry registry, C cache, java.lang.String name, java.lang.String... tags)
Caffeine.recordStats() prior to building the cache
for metrics to be recorded.registry - The registry to bind metrics to.cache - The cache to instrument.name - The name prefix of the metrics.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 com.github.benmanes.caffeine.cache.AsyncLoadingCache> C monitor(MeterRegistry registry, C cache, java.lang.String name, java.lang.Iterable<Tag> tags)
Caffeine.recordStats() prior to building the cache
for metrics to be recorded.registry - The registry to bind metrics to.cache - The cache to instrument.name - The name prefix of the metrics.tags - Tags to apply to all recorded metrics.CacheStatspublic void bindTo(MeterRegistry registry)
bindTo in interface MeterBinder