Record cache metrics
The following metrics are now tracked for Caffeine trough Micrometer:
- size
- puts
- gets (hits and misses)
- evictions
These metrics are recorded separately for each cache. The caches are now statically created which is a requirement of Actuator so it can automatically setup registries with Micrometer. Using a cache which has not been defined at startup will now lead to an exception.
Example
http -v localhost/api/management/core/prometheus 'Authorization:Bearer <ADMIN TOKEN>'
# HELP cache_size The number of entries in this cache. This may be an approximation, depending on the type of cache.
# TYPE cache_size gauge
cache_size{cache="rendered-texts",cacheManager="cacheManager",name="rendered-texts",} 9.0
cache_size{cache="entity",cacheManager="cacheManager",name="entity",} 90.0
cache_size{cache="room.id-by-shortid",cacheManager="cacheManager",name="room.id-by-shortid",} 3.0
cache_size{cache="statistics",cacheManager="cacheManager",name="statistics",} 1.0
# HELP cache_gets_total the number of times cache lookup methods have returned an uncached (newly loaded) value, or null
# TYPE cache_gets_total counter
cache_gets_total{cache="room.id-by-shortid",cacheManager="cacheManager",name="room.id-by-shortid",result="miss",} 3.0
cache_gets_total{cache="statistics",cacheManager="cacheManager",name="statistics",result="hit",} 6.0
cache_gets_total{cache="rendered-texts",cacheManager="cacheManager",name="rendered-texts",result="miss",} 177.0
cache_gets_total{cache="entity",cacheManager="cacheManager",name="entity",result="hit",} 107.0
cache_gets_total{cache="room.id-by-shortid",cacheManager="cacheManager",name="room.id-by-shortid",result="hit",} 2.0
cache_gets_total{cache="rendered-texts",cacheManager="cacheManager",name="rendered-texts",result="hit",} 20.0
cache_gets_total{cache="statistics",cacheManager="cacheManager",name="statistics",result="miss",} 1.0
cache_gets_total{cache="entity",cacheManager="cacheManager",name="entity",result="miss",} 90.0
# HELP cache_evictions_total cache evictions
# TYPE cache_evictions_total counter
cache_evictions_total{cache="rendered-texts",cacheManager="cacheManager",name="rendered-texts",} 0.0
cache_evictions_total{cache="entity",cacheManager="cacheManager",name="entity",} 0.0
cache_evictions_total{cache="room.id-by-shortid",cacheManager="cacheManager",name="room.id-by-shortid",} 0.0
cache_evictions_total{cache="statistics",cacheManager="cacheManager",name="statistics",} 0.0
# HELP cache_puts_total The number of entries added to the cache
# TYPE cache_puts_total counter
cache_puts_total{cache="rendered-texts",cacheManager="cacheManager",name="rendered-texts",} 0.0
cache_puts_total{cache="entity",cacheManager="cacheManager",name="entity",} 0.0
cache_puts_total{cache="room.id-by-shortid",cacheManager="cacheManager",name="room.id-by-shortid",} 0.0
cache_puts_total{cache="statistics",cacheManager="cacheManager",name="statistics",} 0.0
Edited by Daniel Gerhardt