io.dropwizard.metrics5.annotation.Gauge Maven / Gradle / Ivy
package io.dropwizard.metrics5.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* An annotation for marking a method of an annotated object as a gauge.
*
* Given a method like this:
*
* {@literal @}Gauge(name = "queueSize")
* public int getQueueSize() {
* return queue.size;
* }
*
*
* A gauge for the defining class with the name {@code queueSize} will be created which uses the
* annotated method's return value as its value.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE })
public @interface Gauge {
/**
* @return The gauge's name.
*/
String name() default "";
/**
* @return If {@code true}, use the given name as an absolute name. If {@code false}, use the given name
* relative to the annotated class.
*/
boolean absolute() default false;
}