Refine search
final String name = chooseName(annotation.name(), annotation.absolute(), task); taskExecutor = new TimedTask(taskExecutor, metricRegistry.timer(name)); final String name = chooseName(annotation.name(), annotation.absolute(), task); taskExecutor = new MeteredTask(taskExecutor, metricRegistry.meter(name));
public MeteredMetricsFilter(MetricRegistry metricRegistry, ResourceInfo resourceInfo) { final Metered annotation = resourceInfo.getResourceMethod().getAnnotation(Metered.class); meter = metricRegistry.meter(chooseName(annotation.name(), annotation.absolute(), resourceInfo.getResourceMethod())); } @Override
@Metered(name = "myMeteredNameAbsolute", absolute = true) public void meteredNameAbsolute() { } }
public EventDriverMetrics(final Class<?> endpointClass, MetricRegistry metrics) { final Class<?> klass = endpointClass; Metered metered = klass.getAnnotation(Metered.class); Timed timed = klass.getAnnotation(Timed.class); ExceptionMetered em = klass.getAnnotation(ExceptionMetered.class); this.onTextMeter = metered != null ? Optional.of(metrics.meter(MetricRegistry.name(metered.name(), klass.getName(), OnMessage.class.getSimpleName()))) : Optional.empty(); this.countOpened = metered != null ? Optional.of(metrics.counter(MetricRegistry.name(metered.name(), klass.getName(), OPEN_CONNECTIONS))) : Optional.empty(); this.timer = timed != null ? Optional.of(metrics.timer(MetricRegistry.name(timed.name(), klass.getName()))) : Optional.empty(); this.exceptionMetered = em != null ? Optional.of(metrics.meter(MetricRegistry.name(em.name(), klass.getName(), OnError.class.getSimpleName()))) : Optional.empty(); } public static final String OPEN_CONNECTIONS = "openConnections";
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() + "]"); }
@Override public String getName(Metered annotation) { return annotation.name(); }
@Override public boolean isAbsoluteName(Metered annotation) { return annotation.absolute(); }
@Metered private void meteredPrivate() { }
public EventDriverMetrics(final Class<?> endpointClass, MetricRegistry metrics) { final Class<?> klass = endpointClass; Metered metered = klass.getAnnotation(Metered.class); Timed timed = klass.getAnnotation(Timed.class); ExceptionMetered em = klass.getAnnotation(ExceptionMetered.class); this.onTextMeter = metered != null ? Optional.of(metrics.meter(MetricRegistry.name(metered.name(), klass.getName(), OnMessage.class.getSimpleName()))) : Optional.empty(); this.countOpened = metered != null ? Optional.of(metrics.counter(MetricRegistry.name(metered.name(), klass.getName(), OPEN_CONNECTIONS))) : Optional.empty(); this.timer = timed != null ? Optional.of(metrics.timer(MetricRegistry.name(timed.name(), klass.getName()))) : Optional.empty(); this.exceptionMetered = em != null ? Optional.of(metrics.meter(MetricRegistry.name(em.name(), klass.getName(), OnError.class.getSimpleName()))) : Optional.empty(); } public static final String OPEN_CONNECTIONS = "openConnections";
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() + "]"); }
@Metered(absolute = true) public void meteredAbsolute() { }
final String name = chooseName(annotation.name(), annotation.absolute(), task); taskExecutor = new TimedTask(taskExecutor, metricRegistry.timer(name)); final String name = chooseName(annotation.name(), annotation.absolute(), task); taskExecutor = new MeteredTask(taskExecutor, metricRegistry.meter(name));
private String metricName(Annotation annotation) { if (CachedGauge.class.isInstance(annotation)) return ((CachedGauge) annotation).name(); else if (Counted.class.isInstance(annotation)) return ((Counted) annotation).name(); else if (ExceptionMetered.class.isInstance(annotation)) return ((ExceptionMetered) annotation).name(); else if (Gauge.class.isInstance(annotation)) return ((Gauge) annotation).name(); else if (Metered.class.isInstance(annotation)) return ((Metered) annotation).name(); else if (Timed.class.isInstance(annotation)) return ((Timed) annotation).name(); else throw new IllegalArgumentException("Unsupported Metrics forMethod [" + annotation.getClass().getName() + "]"); }
@Transactional(readOnly = true, transactionManager = "ticketTransactionManager") @Timed(name = "GET_TICKETS_TIMER") @Metered(name = "GET_TICKETS_METER") @Counted(name = "GET_TICKETS_COUNTER", monotonic = true) @Override public Collection<Ticket> getTickets(final Predicate<Ticket> predicate) { final Collection<Ticket> c = new HashSet<>(this.ticketRegistry.getTickets()); final Iterator<Ticket> it = c.iterator(); while (it.hasNext()) { if (!predicate.apply(it.next())) { it.remove(); } } return c; }
@Metered public void meteredDefault() { }
final String name = chooseName(annotation.name(), annotation.absolute(), method); final Timer timer = registry.timer(name); dispatcher = new TimedRequestDispatcher(dispatcher, timer); final String name = chooseName(annotation.name(), annotation.absolute(), method); final Meter meter = registry.meter(name); dispatcher = new MeteredRequestDispatcher(dispatcher, meter);