Package com.codahale.metrics.annotation
Annotation Type CachedGauge
An annotation for marking a method as a gauge, which caches the result for a specified time.
Given a method like this:
@CachedGauge(name = "queueSize", timeout = 30, timeoutUnit = TimeUnit.SECONDS)
public int getQueueSize() {
return queue.getSize();
}
A gauge for the defining class with the name queueSize will be created which uses the annotated method's return value as its value, and which caches the result for 30 seconds.
- Since:
- 3.1
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional Elements
-
Element Details
-
timeout
long timeout- Returns:
- The amount of time to cache the result
-
-
-
name
String name- Returns:
- The name of the counter.
- Default:
- ""
-
absolute
boolean absolute- Returns:
- If
true, use the given name as an absolute name. Iffalse, use the given name relative to the annotated class.
- Default:
- false
-
timeoutUnit
TimeUnit timeoutUnit- Returns:
- The unit of timeout
- Default:
- MILLISECONDS
-