Annotation Type ExceptionMetered


  • @Retention(RUNTIME)
    @Target(METHOD)
    public @interface ExceptionMetered
    An annotation for marking a method of an annotated object as metered.

    Given a method like this:

    
         @ExceptionMetered(name = "fancyName", cause=IllegalArgumentException.class)
         public String fancyName(String name) {
             return "Sir Captain " + name;
         }
     

    A meter for the defining class with the name fancyName will be created and each time the #fancyName(String) throws an exception of type cause (or a subclass), the meter will be marked.

    A name for the metric can be specified as an annotation parameter, otherwise, the metric will be named based on the method name.

    For instance, given a declaration of

    
         @ExceptionMetered
         public String fancyName(String name) {
             return "Sir Captain " + name;
         }
     

    A meter named fancyName.exceptions will be created and marked every time an exception is thrown.

    • Field Summary

      Fields 
      Modifier and Type Fields Description
      static java.lang.String DEFAULT_NAME_SUFFIX
      The default suffix for meter names.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean absolute
      If true, use the given name as an absolute name.
      java.lang.Class<? extends java.lang.Throwable> cause
      The type of exceptions that the meter will catch and count.
      java.lang.String name
      The name of the meter.
    • Field Detail

      • DEFAULT_NAME_SUFFIX

        static final java.lang.String DEFAULT_NAME_SUFFIX
        The default suffix for meter names.
    • Element Detail

      • name

        java.lang.String name
        The name of the meter. If not specified, the meter will be given a name based on the method it decorates and the suffix "Exceptions".
        Default:
        ""
      • absolute

        boolean absolute
        If true, use the given name as an absolute name. If false, use the given name relative to the annotated class.
        Default:
        false
      • cause

        java.lang.Class<? extends java.lang.Throwable> cause
        The type of exceptions that the meter will catch and count.
        Default:
        java.lang.Exception.class