Spring Data's RedisCache
exposes since version 2.4 a CacheStatistics
interface that exposes the following metrics:
- Number of puts, gets and deletes
- Hits/misses
The following metrics are specific to the Redis Cache implementation:
- Number of pending requests (that have not yet been answered and either result in a hit or miss)
- Lock wait duration (if cache locking is enabled)
It would make sense to expose at least the basic metrics through the actuator. The additional metrics (pending requests, lock wait) would be nice to have.
For reference, an earlier ticket (#4966) was declined as we initially decided against metrics since those were based on server-internal Redis counters. CacheStatistics
reflects cache-local metrics that aren't replicated or shared with other cache instances.
Comment From: snicoll
Thanks for improving Redis support in that direction. I've had a look to CacheStatistics
and I think we could relatively easily implement io.micrometer.core.instrument.binder.cache.CacheMeterBinder
for it. It's a bit unfortunate that we can't do that neither in Micrometer nor in Spring Data but that topic was already discussed.
Comment From: snicoll
I've started to work on an implementation but, unfortunately, statistics do not seem to be exposed although it is enabled for the cache. I think I'd need some help from @mp911de to figure out what I've done wrong.