com.yammer.metrics.annotation
Annotation Type ExceptionMetered


@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface ExceptionMetered

An annotation for marking a method of a Guice-provided object as metered.

Given a method like this:


     \@ExceptionMetered(name = "fancyName", eventType = "namings", rateUnit = TimeUnit.SECONDS,
 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.

By default, the annotation default to capturing all exceptions (subclasses of Exception) and will use the default event-type of "exceptions".

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 fancyNameExceptionMetric will be created with event-type named "exceptions". The meter will be marked every time an exception is thrown.


Optional Element Summary
 Class<? extends Throwable> cause
          The type of exceptions that the meter will catch and count.
 String eventType
          The name of the type of events the meter is measuring.
 String group
          The group of the timer.
 String name
          The name of the meter.
 TimeUnit rateUnit
          The time unit of the meter's rate.
 String type
          The type of the timer.
 

group

public abstract String group
The group of the timer. If not specified, the meter will be given a group based on the package.

Default:
""

type

public abstract String type
The type of the timer. If not specified the meter will be given a type based on the class name.

Default:
""

name

public abstract 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:
""

eventType

public abstract String eventType
The name of the type of events the meter is measuring. The event type defaults to "exceptions".

Default:
"exceptions"

rateUnit

public abstract TimeUnit rateUnit
The time unit of the meter's rate. Defaults to Seconds.

Default:
java.util.concurrent.TimeUnit.SECONDS

cause

public abstract Class<? extends Throwable> cause
The type of exceptions that the meter will catch and count.

Default:
java.lang.Exception.class


Copyright © 2012. All Rights Reserved.