Search in sources :

Example 1 with ResponseMetered

use of com.codahale.metrics.annotation.ResponseMetered in project metrics by dropwizard.

the class InstrumentedResourceMethodApplicationListener method registerMetricsForModel.

private void registerMetricsForModel(ResourceModel resourceModel) {
    for (final Resource resource : resourceModel.getResources()) {
        final Timed classLevelTimed = getClassLevelAnnotation(resource, Timed.class);
        final Metered classLevelMetered = getClassLevelAnnotation(resource, Metered.class);
        final ExceptionMetered classLevelExceptionMetered = getClassLevelAnnotation(resource, ExceptionMetered.class);
        final ResponseMetered classLevelResponseMetered = getClassLevelAnnotation(resource, ResponseMetered.class);
        for (final ResourceMethod method : resource.getAllMethods()) {
            registerTimedAnnotations(method, classLevelTimed);
            registerMeteredAnnotations(method, classLevelMetered);
            registerExceptionMeteredAnnotations(method, classLevelExceptionMetered);
            registerResponseMeteredAnnotations(method, classLevelResponseMetered);
        }
        for (final Resource childResource : resource.getChildResources()) {
            final Timed classLevelTimedChild = getClassLevelAnnotation(childResource, Timed.class);
            final Metered classLevelMeteredChild = getClassLevelAnnotation(childResource, Metered.class);
            final ExceptionMetered classLevelExceptionMeteredChild = getClassLevelAnnotation(childResource, ExceptionMetered.class);
            final ResponseMetered classLevelResponseMeteredChild = getClassLevelAnnotation(childResource, ResponseMetered.class);
            for (final ResourceMethod method : childResource.getAllMethods()) {
                registerTimedAnnotations(method, classLevelTimedChild);
                registerMeteredAnnotations(method, classLevelMeteredChild);
                registerExceptionMeteredAnnotations(method, classLevelExceptionMeteredChild);
                registerResponseMeteredAnnotations(method, classLevelResponseMeteredChild);
            }
        }
    }
}
Also used : ResponseMetered(com.codahale.metrics.annotation.ResponseMetered) ExceptionMetered(com.codahale.metrics.annotation.ExceptionMetered) Metered(com.codahale.metrics.annotation.Metered) ResponseMetered(com.codahale.metrics.annotation.ResponseMetered) Timed(com.codahale.metrics.annotation.Timed) Resource(org.glassfish.jersey.server.model.Resource) ExceptionMetered(com.codahale.metrics.annotation.ExceptionMetered) ResourceMethod(org.glassfish.jersey.server.model.ResourceMethod)

Example 2 with ResponseMetered

use of com.codahale.metrics.annotation.ResponseMetered in project metrics by dropwizard.

the class InstrumentedResourceMethodApplicationListener method registerResponseMeteredAnnotations.

private void registerResponseMeteredAnnotations(final ResourceMethod method, final ResponseMetered classLevelResponseMetered) {
    final Method definitionMethod = method.getInvocable().getDefinitionMethod();
    if (classLevelResponseMetered != null) {
        responseMeters.putIfAbsent(definitionMethod, new ResponseMeterMetric(metrics, method, classLevelResponseMetered));
        return;
    }
    final ResponseMetered annotation = definitionMethod.getAnnotation(ResponseMetered.class);
    if (annotation != null) {
        responseMeters.putIfAbsent(definitionMethod, new ResponseMeterMetric(metrics, method, annotation));
    }
}
Also used : ResponseMetered(com.codahale.metrics.annotation.ResponseMetered) ResourceMethod(org.glassfish.jersey.server.model.ResourceMethod) Method(java.lang.reflect.Method)

Example 3 with ResponseMetered

use of com.codahale.metrics.annotation.ResponseMetered in project metrics by dropwizard.

the class InstrumentedResourceMethodApplicationListener method registerMetricsForModel.

private void registerMetricsForModel(ResourceModel resourceModel) {
    for (final Resource resource : resourceModel.getResources()) {
        final Timed classLevelTimed = getClassLevelAnnotation(resource, Timed.class);
        final Metered classLevelMetered = getClassLevelAnnotation(resource, Metered.class);
        final ExceptionMetered classLevelExceptionMetered = getClassLevelAnnotation(resource, ExceptionMetered.class);
        final ResponseMetered classLevelResponseMetered = getClassLevelAnnotation(resource, ResponseMetered.class);
        for (final ResourceMethod method : resource.getAllMethods()) {
            registerTimedAnnotations(method, classLevelTimed);
            registerMeteredAnnotations(method, classLevelMetered);
            registerExceptionMeteredAnnotations(method, classLevelExceptionMetered);
            registerResponseMeteredAnnotations(method, classLevelResponseMetered);
        }
        for (final Resource childResource : resource.getChildResources()) {
            final Timed classLevelTimedChild = getClassLevelAnnotation(childResource, Timed.class);
            final Metered classLevelMeteredChild = getClassLevelAnnotation(childResource, Metered.class);
            final ExceptionMetered classLevelExceptionMeteredChild = getClassLevelAnnotation(childResource, ExceptionMetered.class);
            final ResponseMetered classLevelResponseMeteredChild = getClassLevelAnnotation(childResource, ResponseMetered.class);
            for (final ResourceMethod method : childResource.getAllMethods()) {
                registerTimedAnnotations(method, classLevelTimedChild);
                registerMeteredAnnotations(method, classLevelMeteredChild);
                registerExceptionMeteredAnnotations(method, classLevelExceptionMeteredChild);
                registerResponseMeteredAnnotations(method, classLevelResponseMeteredChild);
            }
        }
    }
}
Also used : ResponseMetered(com.codahale.metrics.annotation.ResponseMetered) ExceptionMetered(com.codahale.metrics.annotation.ExceptionMetered) Metered(com.codahale.metrics.annotation.Metered) ResponseMetered(com.codahale.metrics.annotation.ResponseMetered) Timed(com.codahale.metrics.annotation.Timed) Resource(org.glassfish.jersey.server.model.Resource) ExceptionMetered(com.codahale.metrics.annotation.ExceptionMetered) ResourceMethod(org.glassfish.jersey.server.model.ResourceMethod)

Example 4 with ResponseMetered

use of com.codahale.metrics.annotation.ResponseMetered in project metrics by dropwizard.

the class InstrumentedResourceMethodApplicationListener method registerResponseMeteredAnnotations.

private void registerResponseMeteredAnnotations(final ResourceMethod method, final ResponseMetered classLevelResponseMetered) {
    final Method definitionMethod = method.getInvocable().getDefinitionMethod();
    if (classLevelResponseMetered != null) {
        responseMeters.putIfAbsent(definitionMethod, new ResponseMeterMetric(metrics, method, classLevelResponseMetered));
        return;
    }
    final ResponseMetered annotation = definitionMethod.getAnnotation(ResponseMetered.class);
    if (annotation != null) {
        responseMeters.putIfAbsent(definitionMethod, new ResponseMeterMetric(metrics, method, annotation));
    }
}
Also used : ResponseMetered(com.codahale.metrics.annotation.ResponseMetered) ResourceMethod(org.glassfish.jersey.server.model.ResourceMethod) Method(java.lang.reflect.Method)

Aggregations

ResponseMetered (com.codahale.metrics.annotation.ResponseMetered)4 ResourceMethod (org.glassfish.jersey.server.model.ResourceMethod)4 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)2 Metered (com.codahale.metrics.annotation.Metered)2 Timed (com.codahale.metrics.annotation.Timed)2 Method (java.lang.reflect.Method)2 Resource (org.glassfish.jersey.server.model.Resource)2