com.yammer.metrics.annotation.Timed Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metrics-annotation Show documentation
Show all versions of metrics-annotation Show documentation
A dependency-less package of just the annotations used by other Metrics modules.
package com.yammer.metrics.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.concurrent.TimeUnit;
/**
* An annotation for marking a method of a Guice-provided object as timed.
*
* Given a method like this:
*
* \@Timed(name = "fancyName", rateUnit = TimeUnit.SECONDS, durationUnit =
* TimeUnit.MICROSECONDS)
* public String fancyName(String name) {
* return "Sir Captain " + name;
* }
*
*
* A timer for the defining class with the name {@code fancyName} will be created and each time the
* {@code #fancyName(String)} method is invoked, the method's execution will be timed.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Timed {
/**
* The group of the timer.
*/
String group() default "";
/**
* The type of the timer.
*/
String type() default "";
/**
* The name of the timer.
*/
String name() default "";
/**
* The time unit of the timer's rate.
*/
TimeUnit rateUnit() default TimeUnit.SECONDS;
/**
* The time unit of the timer's duration.
*/
TimeUnit durationUnit() default TimeUnit.MILLISECONDS;
}