Package com.codahale.metrics.annotation

Examples of com.codahale.metrics.annotation.Timed


public class TimedMetricsFilter extends AbstractMetricsFilter {

    private final Timer timer;

    public TimedMetricsFilter(MetricRegistry metricRegistry, ResourceInfo resourceInfo) {
        final Timed annotation = resourceInfo.getResourceMethod().getAnnotation(Timed.class);
        timer = metricRegistry.timer(chooseName(annotation.name(), annotation.absolute(), resourceInfo.getResourceMethod()));
    }
View Full Code Here


    }

    private void registerTimedAnnotations(final ImmutableMap.Builder<Method, Timer> builder,
                                          final ResourceMethod method) {
        final Method definitionMethod = method.getInvocable().getDefinitionMethod();
        final Timed annotation = definitionMethod.getAnnotation(Timed.class);

        if (annotation != null) {
            builder.put(definitionMethod, timerMetric(this.metrics, method, annotation));
        }
    }
View Full Code Here

        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;
    }
View Full Code Here

class TimedInterceptor implements MethodInterceptor {

    static final String TIMED_SUFFIX = "timer";

    static MethodInterceptor forMethod(MetricRegistry metricRegistry, Class<?> klass, Method method) {
        final Timed annotation = method.getAnnotation(Timed.class);
        if (annotation != null) {
            final Timer timer = metricRegistry.timer(determineName(annotation, klass, method));
            return new TimedInterceptor(timer);
        }
        return null;
View Full Code Here

        try {
            Method executeMethod = task.getClass().getMethod("execute",
                    ImmutableMultimap.class, PrintWriter.class);

            if(executeMethod.isAnnotationPresent(Timed.class)) {
                Timed annotation = executeMethod.getAnnotation(Timed.class);
                String name = chooseName(annotation.name(),
                        annotation.absolute(),
                        task);
                Timer timer = metricRegistry.timer(name);
                taskExecutor = new TimedTask(taskExecutor, timer);
            }

            if(executeMethod.isAnnotationPresent(Metered.class)) {
                Metered annotation = executeMethod.getAnnotation(Metered.class);
                String name = chooseName(annotation.name(),
                                        annotation.absolute(),
                                        task);
                Meter meter = metricRegistry.meter(name);
                taskExecutor = new MeteredTask(taskExecutor, meter);
            }

            if(executeMethod.isAnnotationPresent(ExceptionMetered.class)) {
                ExceptionMetered annotation = executeMethod.getAnnotation(ExceptionMetered.class);
                String name = chooseName(annotation.name(),
                                        annotation.absolute(),
                                        task,
                                        ExceptionMetered.DEFAULT_NAME_SUFFIX);
                Meter exceptionMeter = metricRegistry.meter(name);
                taskExecutor = new ExceptionMeteredTask(taskExecutor, exceptionMeter, annotation.cause());
            }
        } catch (NoSuchMethodException e) {
        }

        taskExecutors.put(task, taskExecutor);
View Full Code Here

        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;
    }
View Full Code Here

TOP

Related Classes of com.codahale.metrics.annotation.Timed

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.