Package com.codahale.metrics.annotation
Annotation Type Counted
@Inherited
@Documented
@Retention(RUNTIME)
@Target({TYPE,CONSTRUCTOR,METHOD,ANNOTATION_TYPE})
public @interface Counted
An annotation for marking a method of an annotated object as counted.
Given a method like this:
@Counted(name = "fancyName")
public String fancyName(String name) {
return "Sir Captain " + name;
}
A counter for the defining class with the name fancyName
will be created and each time the
#fancyName(String)
method is invoked, the counter will be marked.
- Since:
- 3.1
-
Optional Element Summary
-
Element Details
-
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. When annotating a class, this must befalse
.
- Default:
- false
-
monotonic
boolean monotonic- Returns:
- If
false
(default), the counter is decremented when the annotated method returns, counting current invocations of the annotated method. Iftrue
, the counter increases monotonically, counting total invocations of the annotated method.
- Default:
- false
-