Class CacheMeterBinder<C>
java.lang.Object
io.micrometer.core.instrument.binder.cache.CacheMeterBinder<C>
- All Implemented Interfaces:
MeterBinder
- Direct Known Subclasses:
CaffeineCacheMetrics,EhCache2Metrics,GuavaCacheMetrics,HazelcastCacheMetrics,JCacheMetrics
A common base class for cache metrics that ensures that all caches are instrumented
with the same basic set of metrics while allowing for additional detail that is
specific to an individual implementation.
Having this common base set of metrics ensures that you can reason about basic cache performance in a dimensional slice that spans different cache implementations in your application.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidBind detailed metrics that are particular to the cache implementation, e.g.final voidbindTo(MeterRegistry registry) protected abstract @Nullable Longprotected @Nullable CgetCache()protected abstract longhitCount()protected abstract @Nullable Longprotected abstract longputCount()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 abstract @Nullable Longsize()MOST cache implementations provide a means of retrieving the number of entries.
-
Constructor Details
-
CacheMeterBinder
-
-
Method Details
-
getCache
-
bindTo
- Specified by:
bindToin interfaceMeterBinder
-
size
MOST cache implementations provide a means of retrieving the number of entries. Even if- Returns:
- Total number of cache entries. This value may go up or down with puts,
removes, and evictions. Returns
nullif the cache implementation does not provide a way to track cache size.
-
hitCount
protected abstract long hitCount()- Returns:
- Get requests that resulted in a "hit" against an existing cache entry. Monotonically increasing hit count. Returns -1 if the cache implementation does not support this.
-
missCount
- Returns:
- Get requests that resulted in a "miss", or didn't match an existing cache
entry. Monotonically increasing count. Returns
nullif the cache implementation does not provide a way to track miss count, especially in distributed caches.
-
evictionCount
- Returns:
- Total number of entries that have been evicted from the cache.
Monotonically increasing eviction count. Returns
nullif the cache implementation does not support eviction, or does not provide a way to track the eviction count.
-
putCount
protected abstract 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. Note that Guava/Caffeine caches don't count manual puts. Returns -1 if the cache implementation does not support this.- Returns:
- Total number of entries added to the cache. Monotonically increasing count.
-
bindImplementationSpecificMetrics
Bind detailed metrics that are particular to the cache implementation, e.g. load duration for Caffeine caches, heap and disk size for EhCache caches. These metrics are above and beyond the basic set of metrics that is common to all caches.- Parameters:
registry- The registry to bind metrics to.
-
getTagsWithCacheName
-