Log a warning when instrumenting a cache that is not recording stats in CaffeineCacheMetrics by izeye · Pull Request #5402 · micrometer-metrics/micrometer (original) (raw)

@izeye

This PR changes to log a warning when instrumenting a cache that is not recording statistics in the CaffeineCacheMetrics.

See gh-5066

@izeye izeye mentioned this pull request

Aug 25, 2024

shakuzen

@izeye

@izeye

The Guava cache also has the same concept, but it doesn't seem to have an API corresponding to Policy.isRecordingStats() from the Caffeine cache.

@izeye

In addition to logging the warning, we can try not to register meters that depend on the Caffeine.recordStats() call at all instead of registering zero-valued meters.

@shakuzen

In addition to logging the warning, we can try not to register meters that depend on the Caffeine.recordStats() call at all instead of registering zero-valued meters.

That sounds like a good idea to me. It will be more clear we don't have metrics for those rather than saying the metrics for those are 0. Do you want to update this pull request with that or make a separate PR for it?

@izeye

@shakuzen Thanks for the feedback!

Looking into its implementation details, it seems a bit tricky, so it would be better to be discussed in a separate issue. I can try another PR if it's proven to be okay in the issue.

@izeye izeye deleted the gh-gh-5066 branch

August 29, 2024 03:18

@izeye izeye mentioned this pull request

Aug 29, 2024

@izeye

Looking into its implementation details, it seems a bit tricky, so it would be better to be discussed in a separate issue.

I created #5408.

@izeye izeye mentioned this pull request

Aug 30, 2024

3 tasks

@izeye

The Guava cache also has the same concept, but it doesn't seem to have an API corresponding to Policy.isRecordingStats() from the Caffeine cache.

I created google/guava#7381 to see if it could be improved.

This was referenced

Jun 3, 2026

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})