Search in sources :

Example 26 with ResourceMethod

use of org.glassfish.jersey.server.model.ResourceMethod in project metrics by dropwizard.

the class InstrumentedResourceMethodApplicationListener method registerExceptionMeteredAnnotations.

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

Example 27 with ResourceMethod

use of org.glassfish.jersey.server.model.ResourceMethod in project metrics by dropwizard.

the class InstrumentedResourceMethodApplicationListener method chooseName.

protected static String chooseName(final String explicitName, final boolean absolute, final ResourceMethod method, final String... suffixes) {
    final Method definitionMethod = method.getInvocable().getDefinitionMethod();
    final String metricName;
    if (explicitName != null && !explicitName.isEmpty()) {
        metricName = absolute ? explicitName : name(definitionMethod.getDeclaringClass(), explicitName);
    } else {
        metricName = name(definitionMethod.getDeclaringClass(), definitionMethod.getName());
    }
    return name(metricName, suffixes);
}
Also used : ResourceMethod(org.glassfish.jersey.server.model.ResourceMethod) Method(java.lang.reflect.Method)

Example 28 with ResourceMethod

use of org.glassfish.jersey.server.model.ResourceMethod in project metrics by dropwizard.

the class InstrumentedResourceMethodApplicationListener method registerMeteredAnnotations.

private void registerMeteredAnnotations(final ResourceMethod method, final Metered classLevelMetered) {
    final Method definitionMethod = method.getInvocable().getDefinitionMethod();
    if (classLevelMetered != null) {
        meters.putIfAbsent(definitionMethod, meterMetric(metrics, method, classLevelMetered));
        return;
    }
    final Metered annotation = definitionMethod.getAnnotation(Metered.class);
    if (annotation != null) {
        meters.putIfAbsent(definitionMethod, meterMetric(metrics, method, annotation));
    }
}
Also used : ExceptionMetered(com.codahale.metrics.annotation.ExceptionMetered) Metered(com.codahale.metrics.annotation.Metered) ResponseMetered(com.codahale.metrics.annotation.ResponseMetered) ResourceMethod(org.glassfish.jersey.server.model.ResourceMethod) Method(java.lang.reflect.Method)

Example 29 with ResourceMethod

use of org.glassfish.jersey.server.model.ResourceMethod in project metrics by dropwizard.

the class InstrumentedResourceMethodApplicationListener method chooseName.

protected static String chooseName(final String explicitName, final boolean absolute, final ResourceMethod method, final String... suffixes) {
    final Method definitionMethod = method.getInvocable().getDefinitionMethod();
    final String metricName;
    if (explicitName != null && !explicitName.isEmpty()) {
        metricName = absolute ? explicitName : name(definitionMethod.getDeclaringClass(), explicitName);
    } else {
        metricName = name(definitionMethod.getDeclaringClass(), definitionMethod.getName());
    }
    return name(metricName, suffixes);
}
Also used : ResourceMethod(org.glassfish.jersey.server.model.ResourceMethod) Method(java.lang.reflect.Method)

Example 30 with ResourceMethod

use of org.glassfish.jersey.server.model.ResourceMethod in project metrics by dropwizard.

the class InstrumentedResourceMethodApplicationListener method registerTimedAnnotations.

private void registerTimedAnnotations(final ResourceMethod method, final Timed classLevelTimed) {
    final Method definitionMethod = method.getInvocable().getDefinitionMethod();
    if (classLevelTimed != null) {
        registerTimers(method, definitionMethod, classLevelTimed);
        return;
    }
    final Timed annotation = definitionMethod.getAnnotation(Timed.class);
    if (annotation != null) {
        registerTimers(method, definitionMethod, annotation);
    }
}
Also used : Timed(com.codahale.metrics.annotation.Timed) ResourceMethod(org.glassfish.jersey.server.model.ResourceMethod) Method(java.lang.reflect.Method)

Aggregations

ResourceMethod (org.glassfish.jersey.server.model.ResourceMethod)32 Method (java.lang.reflect.Method)13 Resource (org.glassfish.jersey.server.model.Resource)10 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)6 ResponseMetered (com.codahale.metrics.annotation.ResponseMetered)6 Invocable (org.glassfish.jersey.server.model.Invocable)6 Metered (com.codahale.metrics.annotation.Metered)4 Timed (com.codahale.metrics.annotation.Timed)4 MediaType (javax.ws.rs.core.MediaType)4 HashSet (java.util.HashSet)3 AcceptableMediaType (org.glassfish.jersey.message.internal.AcceptableMediaType)3 RuntimeResource (org.glassfish.jersey.server.model.RuntimeResource)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 HttpMethod (javax.ws.rs.HttpMethod)2 ExtendedUriInfo (org.glassfish.jersey.server.ExtendedUriInfo)2 ResourceMethodStatistics (org.glassfish.jersey.server.monitoring.ResourceMethodStatistics)2 Test (org.junit.Test)2