jhalterman / expiringmap

A high performance thread-safe map that expires entries
Apache License 2.0
1k stars 142 forks source link

Metrics for the ExpiringMap #45

Open costimuraru opened 7 years ago

costimuraru commented 7 years ago

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

jhalterman commented 7 years ago

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.

costimuraru commented 7 years ago

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

jhalterman commented 7 years ago

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.

terrancesnyder commented 5 years ago

👍