Search in sources :

Example 1 with RequestDispatcher

use of com.sun.jersey.spi.dispatch.RequestDispatcher in project metrics by dropwizard.

the class InstrumentedResourceMethodDispatchProvider method create.

@Override
public RequestDispatcher create(AbstractResourceMethod method) {
    RequestDispatcher dispatcher = provider.create(method);
    if (dispatcher == null) {
        return null;
    }
    if (method.getMethod().isAnnotationPresent(Timed.class)) {
        final Timed annotation = method.getMethod().getAnnotation(Timed.class);
        final String name = chooseName(annotation.name(), annotation.absolute(), method);
        final Timer timer = registry.timer(name);
        dispatcher = new TimedRequestDispatcher(dispatcher, timer);
    }
    if (method.getMethod().isAnnotationPresent(Metered.class)) {
        final Metered annotation = method.getMethod().getAnnotation(Metered.class);
        final String name = chooseName(annotation.name(), annotation.absolute(), method);
        final Meter meter = registry.meter(name);
        dispatcher = new MeteredRequestDispatcher(dispatcher, meter);
    }
    if (method.getMethod().isAnnotationPresent(ExceptionMetered.class)) {
        final ExceptionMetered annotation = method.getMethod().getAnnotation(ExceptionMetered.class);
        final String name = chooseName(annotation.name(), annotation.absolute(), method, ExceptionMetered.DEFAULT_NAME_SUFFIX);
        final Meter meter = registry.meter(name);
        dispatcher = new ExceptionMeteredRequestDispatcher(dispatcher, meter, annotation.cause());
    }
    return dispatcher;
}
Also used : Metered(com.codahale.metrics.annotation.Metered) ExceptionMetered(com.codahale.metrics.annotation.ExceptionMetered) Timer(com.codahale.metrics.Timer) Meter(com.codahale.metrics.Meter) Timed(com.codahale.metrics.annotation.Timed) ExceptionMetered(com.codahale.metrics.annotation.ExceptionMetered) RequestDispatcher(com.sun.jersey.spi.dispatch.RequestDispatcher)

Aggregations

Meter (com.codahale.metrics.Meter)1 Timer (com.codahale.metrics.Timer)1 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)1 Metered (com.codahale.metrics.annotation.Metered)1 Timed (com.codahale.metrics.annotation.Timed)1 RequestDispatcher (com.sun.jersey.spi.dispatch.RequestDispatcher)1