All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codahale.metrics.annotation.CachedGauge Maven / Gradle / Ivy

The newest version!
package com.codahale.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 as a gauge, which caches the result for a specified time.
 *
 * 

* Given a method like this: *


 *     {@literal @}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 */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE }) public @interface CachedGauge { /** * @return The name of the counter. */ 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; /** * @return The amount of time to cache the result */ long timeout(); /** * @return The unit of timeout */ TimeUnit timeoutUnit() default TimeUnit.MILLISECONDS; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy