Repository navigation
#168 support for client metrics - #169
Conversation
|
Updated the PR so that blazingcache passes the entry key which triggered the metric update to the update methods of the Gauge (inc, dec, add). |
eolivelli
left a comment
There was a problem hiding this comment.
I am not a fan of the latest change, I left a comment
| * | ||
| * @param entryKey key of the entry which triggered this event. Might be {@code null} | ||
| */ | ||
| void inc(RawString entryKey); |
There was a problem hiding this comment.
I have never seen this before in a Metrics system.
why are you doing this ?
because you want to track per-key metrics ?
this way it does not look like a Metrics system but it is more like a callback/hook mechanism
this is quite dangerous because the metrics provider should be as light weight as possible and it must not impact the execution of BC code.
There was a problem hiding this comment.
We have a multi tenant system where a single cacheclient is used for multiple tenants. To differentiate a cache entry of one tenant from the same entry of another tenant we add a prefix to the actual key.
In blazing cache we end up with something like
tenant1code#entrykey1
tenant2code#entrykey1
We would like to be able to track per-tenant metrics, but this 'tenantcode' extraction should be done by the application, not blazing cache.
With this implementation we can receive the entrykey, extrapolate the code, and log the event on a labeled metric.
There was a problem hiding this comment.
What about naming this class GaugeSet ?
There was a problem hiding this comment.
If you think it's best, I can revert the last changes (go back to the simple gauge without the RawString param) and create a new issue for implementing a hook mechanism so that we can manage the per-tenant labeled metrics directly in our application.
Still, for our use case, we would need a hook on every operation that is now tracked by the metrics and i fear that it might bloat the code more than the parameterized gauge.
There was a problem hiding this comment.
IMHO we can keep this change, just renaming Gauge to GaugeSet
|
Renamed Gauge to GaugeSet |
Added a MetricsProvider interface so that an application can pass it's implementation to che CacheClient (by standard constructor or builder).
The application should provide it's implementation of the Gauge interface, which represents the actual metric. A gauge can be added to, subtracted from and be resetted.
If no MetricsProvided is provided by the application, a standard no-op NullMetricsProvider is used.
The Gauge implementation will also receive the entry key which triggered the metric update so that it may take decisions based on that (ex. manage metric labels). The entry key is passed in RawString format to avoid a useless toString invokation if the entry key is not needed by the implementation.
If an entry key is not available (ex. invalidateByPrefix), null is passed.
The exposed metrics are:
blazingcache.client.puts > number of put operations
blazingcache.client.loads > number of load operations
blazingcache.client.touches > number of touch operations
blazingcache.client.gets > number of get operations
blazingcache.client.fetches > number of fetch operations
blazingcache.client.evictions > number of eviction operations
blazingcache.client.invalidations > number of invalidate operations
blazingcache.client.hits > number of cache hits
blazingcache.client.gets.miss.fetchhit > number of cache misses, followed by a fetch hit
blazingcache.client.gets.miss.fetchmiss > number of cache misses, followed by a fetch miss
blazingcache.client.memory.actualusage > current memory usage as bytes
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004