public TimedMetricsFilter(MetricRegistry metricRegistry, ResourceInfo resourceInfo) { final Timed annotation = resourceInfo.getResourceMethod().getAnnotation(Timed.class); timer = metricRegistry.timer(chooseName(annotation.name(), annotation.absolute(), resourceInfo.getResourceMethod())); }
final Timed annotation = executeMethod.getAnnotation(Timed.class); final String name = chooseName(annotation.name(), annotation.absolute(), task); taskExecutor = new TimedTask(taskExecutor, metricRegistry.timer(name));
@Override protected NamingParameters getNamingParameters(MethodDescription instrumentedMethod) { if (instrumentedMethod.getDeclaredAnnotations().isAnnotationPresent(Timed.class)) { final Timed timed = instrumentedMethod.getDeclaredAnnotations().ofType(Timed.class).loadSilent(); return new NamingParameters(timed.name(), timed.absolute()); } else { return new NamingParameters("", false); } }
static String forTimedMethod(Class<?> klass, Member member, Timed annotation) { return chooseName(annotation.name(), annotation.absolute(), klass, member); }
@Override public boolean isAbsoluteName(Timed annotation) { return annotation.absolute(); }
@Nonnull @Override public String getNameForTimed(@Nonnull Method method, @Nonnull Timed timed) { if (timed.absolute()) { return timed.name(); } if (timed.name().isEmpty()) { return name(method.getDeclaringClass(), method.getName(), TIMED_SUFFIX); } return name(method.getDeclaringClass(), timed.name()); } }
@Nonnull @Override public String getNameForTimed(@Nonnull Method method, @Nonnull Timed timed) { if (timed.absolute()) { return timed.name(); } if (timed.name().isEmpty()) { return name(method.getDeclaringClass(), method.getName(), TIMED_SUFFIX); } return name(method.getDeclaringClass(), timed.name()); } }
/** * Factory method for TimedInvoker. */ private Invoker timed(Invoker invoker, List<Method> timedMethods) { ImmutableMap.Builder<String, Timer> timers = new ImmutableMap.Builder<>(); for (Method m : timedMethods) { Timed annotation = m.getAnnotation(Timed.class); final String name = chooseName(annotation.name(), annotation.absolute(), m); Timer timer = metricRegistry.timer(name); timers.put(m.getName(), timer); } return new InstrumentedInvokers.TimedInvoker(invoker, timers.build()); }
@Nonnull @Override public String getNameForTimed(@Nonnull final Method method, @Nonnull final Timed timed) { if (timed.absolute()) { return timed.name(); } else { return metricName(method, timed.name()); } } }
private boolean isMetricAbsolute(Annotation annotation) { if (extension.<Boolean>getParameter(UseAbsoluteName).orElse(false)) return true; if (CachedGauge.class.isInstance(annotation)) return ((CachedGauge) annotation).absolute(); else if (Counted.class.isInstance(annotation)) return ((Counted) annotation).absolute(); else if (ExceptionMetered.class.isInstance(annotation)) return ((ExceptionMetered) annotation).absolute(); else if (Gauge.class.isInstance(annotation)) return ((Gauge) annotation).absolute(); else if (Metered.class.isInstance(annotation)) return ((Metered) annotation).absolute(); else if (Timed.class.isInstance(annotation)) return ((Timed) annotation).absolute(); else throw new IllegalArgumentException("Unsupported Metrics forMethod [" + annotation.getClass().getName() + "]"); }
private boolean isMetricAbsolute(Annotation annotation) { if (extension.<Boolean>getParameter(UseAbsoluteName).orElse(false)) return true; if (CachedGauge.class.isInstance(annotation)) return ((CachedGauge) annotation).absolute(); else if (Counted.class.isInstance(annotation)) return ((Counted) annotation).absolute(); else if (ExceptionMetered.class.isInstance(annotation)) return ((ExceptionMetered) annotation).absolute(); else if (Gauge.class.isInstance(annotation)) return ((Gauge) annotation).absolute(); else if (Metered.class.isInstance(annotation)) return ((Metered) annotation).absolute(); else if (Timed.class.isInstance(annotation)) return ((Timed) annotation).absolute(); else throw new IllegalArgumentException("Unsupported Metrics forMethod [" + annotation.getClass().getName() + "]"); }
public TimedMetricsFilter(MetricRegistry metricRegistry, ResourceInfo resourceInfo) { final Timed annotation = resourceInfo.getResourceMethod().getAnnotation(Timed.class); timer = metricRegistry.timer(chooseName(annotation.name(), annotation.absolute(), resourceInfo.getResourceMethod())); }
public TimedMetricsFilter(MetricRegistry metricRegistry, ResourceInfo resourceInfo) { final Timed annotation = resourceInfo.getResourceMethod().getAnnotation(Timed.class); timer = metricRegistry.timer(chooseName(annotation.name(), annotation.absolute(), resourceInfo.getResourceMethod())); }
private Timer timerMetric(final MetricRegistry registry, final ResourceMethod method, final Timed timed, final String... suffixes) { final String name = chooseName(timed.name(), timed.absolute(), method, suffixes); return registry.timer(name, () -> new Timer(new ExponentiallyDecayingReservoir(), clock)); }
final Timed annotation = executeMethod.getAnnotation(Timed.class); final String name = chooseName(annotation.name(), annotation.absolute(), task); taskExecutor = new TimedTask(taskExecutor, metricRegistry.timer(name));
final String name = chooseName(annotation.name(), annotation.absolute(), method); final Timer timer = registry.timer(name); dispatcher = new TimedRequestDispatcher(dispatcher, timer);
@Test public void testMixedAnnotations() throws Exception { ListAnnotationResolver annotationProvider = new ListAnnotationResolver( Lists.newArrayList( new MethodAnnotationResolver(), new ClassAnnotationResolver() ) ); Class<MixedAnnotatedClass> klass = MixedAnnotatedClass.class; Method publicMethod = klass.getDeclaredMethod("publicMethod"); Method protectedMethod = klass.getDeclaredMethod("protectedMethod"); Method packagePrivateMethod = klass.getDeclaredMethod("packagePrivateMethod"); Timed classTimed = annotationProvider.findAnnotation(Timed.class, publicMethod); assertNotNull(classTimed); assertFalse(classTimed.absolute()); assertNull(annotationProvider.findAnnotation(Metered.class, publicMethod)); assertNull(annotationProvider.findAnnotation(Counted.class, publicMethod)); assertNotNull(annotationProvider.findAnnotation(Timed.class, protectedMethod)); assertNotNull(annotationProvider.findAnnotation(Metered.class, protectedMethod)); assertNull(annotationProvider.findAnnotation(Counted.class, protectedMethod)); Timed methodTimed = annotationProvider.findAnnotation(Timed.class, packagePrivateMethod); assertNotNull(methodTimed); assertTrue(methodTimed.absolute()); assertNull(annotationProvider.findAnnotation(Metered.class, packagePrivateMethod)); assertNull(annotationProvider.findAnnotation(Counted.class, packagePrivateMethod)); }