Allow for observable size of the cache in Bytes
Is your feature request related to a problem? Please describe. We are currently running into situations where we are attempting to estimate how much memory the cache uses, in order to figure out if its doable to increase the number of cache entries. Currently we cannot observe the actual memory utilization of the process, as we're running it with modified Garbage Collection environment variables.
Describe the solution you'd like I would like to have an Observable on the cache metrics client, that can report on the current size of the cache in Bytes, so that I can have an accurate estimate of the sizes of all caches, not only by entries but of memory footprint.
A suggestion is to not observe the cache and count the size of all objects at that point in time, as that's possibly a very expensive operation. But to instead get the memory size when adding/evicting entries and keep a running tally of it that can be returned by the gauge.
Additional context This would also allow estimates of the average cache entry size using a division of the number of entries with the amount of memory it takes up.
Hi @quoral! I think this sounds like a cool feature, and implementing it should be fairly straightforward. I'll try to find some time to implement this soon