Skip to content
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

Provide API to see if a cache records statistics #7381

Open
3 tasks done
izeye opened this issue Aug 30, 2024 · 4 comments
Open
3 tasks done

Provide API to see if a cache records statistics #7381

izeye opened this issue Aug 30, 2024 · 4 comments
Labels
type=enhancement Make an existing feature better

Comments

@izeye
Copy link

izeye commented Aug 30, 2024

API(s)

com.google.common.cache.Cache

How do you want it to be improved?

It would be nice to provide an API to see if recording statistics in a cache is activated similar to the Policy.isRecordingStats() from the Caffeine cache.

Why do we need it to be improved?

For libraries that collect metrics from a cache, it would be useful to warn a user that metrics won't be collected properly or not to register meters that produce only zero values by using the proposed API.

Example

if (!cache.isRecordingStats()) {
  // Warn a user that the cache doesn't provide statistics.
}
if (cache.isRecordingStats()) {
  // Register meters with its statistics.
}

Current Behavior

It's not possible to know if a cache records statistics.

Desired Behavior

It would be nice to know if a cache records statistics.

Concrete Use Cases

micrometer-metrics/micrometer#5066 and micrometer-metrics/micrometer#5402 (comment) are examples that the proposed API is necessary.

Checklist

@hiddenHunter291
Copy link

Can you assign me this task

@lowasser
Copy link
Contributor

It looks like you're aware of Caffeine's cache -- is there a particular reason you're not using it?

@izeye
Copy link
Author

izeye commented Sep 13, 2024

@lowasser As mentioned in the opening comment, I created this for libraries (ex. Micrometer), not for applications.

@PrimroseZhang
Copy link

Can you assign this to me?

PrimroseZhang added a commit to YujingZHG/guava that referenced this issue Oct 20, 2024
Provide API to see if a cache records statistics
PrimroseZhang added a commit to YujingZHG/guava that referenced this issue Oct 20, 2024
Provide API to see if a cache records statistics
Revert commit
PrimroseZhang added a commit to YujingZHG/guava that referenced this issue Oct 20, 2024
Provide API to see if a cache records statistics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type=enhancement Make an existing feature better
Projects
None yet
Development

No branches or pull requests

4 participants