The metrics-ehcache
module provides InstrumentedEhcache
, a decorator for
Ehcache caches:
final Cache c = new Cache(new CacheConfiguration("test", 100));
MANAGER.addCache(c);
this.cache = InstrumentedEhcache.instrument(registry, c);
Instrumenting an Ehcache
instance creates gauges for all of the Ehcache-provided statistics:
|
The number of times a requested item was found in the cache. |
|
Number of times a requested item was found in the memory store. |
|
Number of times a requested item was found in the off-heap store. |
|
Number of times a requested item was found in the disk store. |
|
Number of times a requested item was not found in the cache. |
|
Number of times a requested item was not found in the memory store. |
|
Number of times a requested item was not found in the off-heap store. |
|
Number of times a requested item was not found in the disk store. |
|
Number of elements stored in the cache. |
|
Number of objects in the memory store. |
|
Number of objects in the off-heap store. |
|
Number of objects in the disk store. |
|
The average get time. Because ehcache supports JDK1.4.2, each get
time uses |
|
The average execution time (in milliseconds) within the last sample period. |
|
The number of cache evictions, since the cache was created, or statistics were cleared. |
|
The number of search executions that have completed in the last second. |
|
A human readable description of the accuracy setting. One of “None”, “Best Effort” or “Guaranteed”. |
It also adds full timers for the cache’s get
and put
methods.
The metrics are all scoped to the cache’s class and name, so a Cache
instance named users
would have metric names like net.sf.ehcache.Cache.users.get
, etc.