Skip to content

Expose cache metrics for RedisCache #22701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mp911de opened this issue Aug 3, 2020 · 2 comments
Closed

Expose cache metrics for RedisCache #22701

mp911de opened this issue Aug 3, 2020 · 2 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@mp911de
Copy link
Member

mp911de commented Aug 3, 2020

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 3, 2020
@snicoll
Copy link
Member

snicoll commented Aug 3, 2020

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.

@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 3, 2020
@snicoll snicoll added this to the 2.x milestone Aug 3, 2020
@snicoll snicoll modified the milestones: 2.x, 2.4.0-M4 Oct 7, 2020
@snicoll snicoll self-assigned this Oct 7, 2020
snicoll added a commit to snicoll/spring-boot that referenced this issue Oct 7, 2020
This commit adds support for Redis cache metrics. Users can opt-in for
statistics using the "spring.cache.redis.enable-statistics" property.

Closes spring-projectsgh-22701
@snicoll
Copy link
Member

snicoll commented Oct 7, 2020

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.

@snicoll snicoll modified the milestones: 2.4.0-M4, 2.4.x Oct 8, 2020
snicoll added a commit to snicoll/spring-boot that referenced this issue Oct 8, 2020
This commit adds support for Redis cache metrics. Users can opt-in for
statistics using the "spring.cache.redis.enable-statistics" property.

Closes spring-projectsgh-22701
@snicoll snicoll modified the milestones: 2.4.x, 2.4.0-M4 Oct 9, 2020
@snicoll snicoll closed this as completed in 34c4c3f Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants