expiringmap icon indicating copy to clipboard operation
expiringmap copied to clipboard

Metrics for the ExpiringMap

Open costimuraru opened this issue 8 years ago • 4 comments

Hey Jonathan,

Great work with this project! I was wondering if there is any plan to add some metrics (eg. https://github.com/dropwizard/metrics) in order to gain some insights into how our application is using the ExpiringMap. Information such as hit ratio, cache requests, number of entries cached, entry load time histograms (how long it takes for a new entry to be created), how many items expired in a given time frame would be super useful.

Cheers, Costi

costimuraru avatar Apr 03 '17 08:04 costimuraru

Hi Costi - Metrics could be useful, but no plans to add them since it's another dependency that many users would not like/want/need. You can of course introspect an ExpiringMap a bit by keeping a watch on the size and use an ExpirationListener, if you like, to observe expiration events.

jhalterman avatar Apr 03 '17 16:04 jhalterman

The dependency issue makes sense, Jonathan! I'll use the listener. As an alternative to using an explicit metrics library, perhaps something likes this might do the trick: https://github.com/google/guava/blob/master/guava/src/com/google/common/cache/CacheStats.java

costimuraru avatar Apr 03 '17 18:04 costimuraru

Edited:

Something like CacheStats (MapStats in our case) would be a good approach, and a good addition to ExpiringMap, if there's enough interest for such a thing. Any interested parties, feel free to speak up.

jhalterman avatar Apr 03 '17 19:04 jhalterman

👍

terrancesnyder avatar Oct 30 '18 03:10 terrancesnyder