001package org.avaje.metric.annotation;
002
003import java.lang.annotation.ElementType;
004import java.lang.annotation.Retention;
005import java.lang.annotation.RetentionPolicy;
006import java.lang.annotation.Target;
007
008/**
009 * Put onto a Class or methods that we want timed execution statistics collected.
010 * <p>
011 * When put on a Class the default is that all public methods on that Class are timed.
012 * </p>
013 * <p>
014 * When put on a method we want to override some of metric naming or only collect timed
015 * execution on very few methods on the class.
016 * </p>
017 */
018@Target({ElementType.TYPE, ElementType.METHOD})
019@Retention(RetentionPolicy.RUNTIME)
020public @interface Timed {
021
022  /**
023   * Set the prefix for short metric names. Typically used at class level to define a common short prefix
024   * to replace the package name for the metrics on the class.
025   * <pre>{@code
026   *
027   * @Timed(perfix="web.api")
028   * public class AdminResource
029   *   ...
030   *
031   * }</pre>
032   *
033   * @return
034   */
035  String prefix() default "";
036
037  /**
038   * Set the method name part of the full metric name.
039   * <p>
040   * This is used when the method name is not appropriate or when there is method overloading and
041   * the otherwise generated unique name is unclear.
042   * <p>
043   * The package and class names are still used and prepended to this name value.
044   */
045  String name() default "";
046
047  /**
048   * Set the full name of the metric.
049   * <p>
050   * Provides a complete replacement of the metric name. The package and class names are not used at all.
051   */
052  String fullName() default "";
053
054
055  /**
056   * Define buckets as a list of millisecond times.
057   * <p>
058   * For example with values of 100, 200, 300 there a with 4 bucket ranges of:
059   * <pre>
060   *      0 to 100 milliseconds
061   *    100 to 200 milliseconds
062   *    200 to 300 milliseconds
063   *    300+       milliseconds
064   * </pre>
065   * <p>
066   * Defining buckets means a BucketTimedMetric will be used instead of a TimedMetric.
067   */
068  int[] buckets() default {};
069}