@NonNullApi @NonNullFields public class GuavaCacheMetrics extends CacheMeterBinder
Constructor and Description |
---|
GuavaCacheMetrics(com.google.common.cache.Cache<?,?> cache,
java.lang.String cacheName,
java.lang.Iterable<Tag> tags) |
Modifier and Type | Method and Description |
---|---|
protected void |
bindImplementationSpecificMetrics(MeterRegistry registry)
Bind detailed metrics that are particular to the cache implementation, e.g.
|
protected java.lang.Long |
evictionCount() |
protected long |
hitCount() |
protected long |
missCount() |
static <C extends com.google.common.cache.Cache> |
monitor(MeterRegistry registry,
C cache,
java.lang.String cacheName,
java.lang.Iterable<Tag> tags)
Record metrics on a Guava cache.
|
static <C extends com.google.common.cache.Cache> |
monitor(MeterRegistry registry,
C cache,
java.lang.String cacheName,
java.lang.String... tags)
Record metrics on a Guava cache.
|
protected long |
putCount()
The put mechanism is unimportant - this count applies to entries added to the cache according to a pre-defined
load function such as exists in Guava/Caffeine caches as well as manual puts.
|
protected java.lang.Long |
size()
MOST cache implementations provide a means of retrieving the number of entries.
|
bindTo, getTagsWithCacheName
public GuavaCacheMetrics(com.google.common.cache.Cache<?,?> cache, java.lang.String cacheName, java.lang.Iterable<Tag> tags)
public static <C extends com.google.common.cache.Cache> C monitor(MeterRegistry registry, C cache, java.lang.String cacheName, java.lang.String... tags)
CacheBuilder.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.CacheStats
public static <C extends com.google.common.cache.Cache> C monitor(MeterRegistry registry, C cache, java.lang.String cacheName, java.lang.Iterable<Tag> tags)
CacheBuilder.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
- The name prefix of the metrics.tags
- Tags to apply to all recorded metrics.CacheStats
protected java.lang.Long size()
CacheMeterBinder
size
in class CacheMeterBinder
null
if the cache implementation does not provide a way to track cache size.protected long hitCount()
hitCount
in class CacheMeterBinder
protected long missCount()
missCount
in class CacheMeterBinder
protected java.lang.Long evictionCount()
evictionCount
in class CacheMeterBinder
null
if the cache implementation does not support eviction, or does not provide a way to track
the eviction count.protected long putCount()
CacheMeterBinder
putCount
in class CacheMeterBinder
protected void bindImplementationSpecificMetrics(MeterRegistry registry)
CacheMeterBinder
bindImplementationSpecificMetrics
in class CacheMeterBinder
registry
- The registry to bind metrics to.