use of org.eclipse.microprofile.metrics.Counter in project Payara by payara.
the class CountedInterceptor method applyInterceptor.
@Override
protected <E extends Member & AnnotatedElement> Object applyInterceptor(InvocationContext context, E element) throws Exception {
MetricsResolver.Of<Counted> counted = resolver.counted(bean.getBeanClass(), element);
Counter counter = (Counter) registry.getMetrics().get(counted.metricName());
if (counter == null) {
throw new IllegalStateException("No counter with name [" + counted.metricName() + "] found in registry [" + registry + "]");
}
counter.inc();
try {
return context.proceed();
} finally {
if (!counted.metricAnnotation().monotonic()) {
counter.dec();
}
}
}
Aggregations