Search in sources :

Example 6 with Timer

use of org.eclipse.microprofile.metrics.Timer in project wildfly-swarm by wildfly-swarm.

the class TimedInterceptor method timedCallable.

private <E extends Member & AnnotatedElement> Object timedCallable(InvocationContext context, E element) throws Exception {
    String name = resolver.timed(bean.getBeanClass(), element).metricName();
    Timer timer = (Timer) registry.getMetrics().get(name);
    if (timer == null) {
        throw new IllegalStateException("No timer with name [" + name + "] found in registry [" + registry + "]");
    }
    Timer.Context time = timer.time();
    try {
        return context.proceed();
    } finally {
        time.stop();
    }
}
Also used : Timer(org.eclipse.microprofile.metrics.Timer)

Aggregations

Timer (org.eclipse.microprofile.metrics.Timer)6 MetricID (org.eclipse.microprofile.metrics.MetricID)3 SimpleTimer (org.eclipse.microprofile.metrics.SimpleTimer)3 Snapshot (org.eclipse.microprofile.metrics.Snapshot)2 Test (org.junit.Test)2 NoSuchRegistryException (fish.payara.microprofile.metrics.exception.NoSuchRegistryException)1 MonitoringDataCollector (fish.payara.monitoring.collect.MonitoringDataCollector)1 FileNotFoundException (java.io.FileNotFoundException)1 Method (java.lang.reflect.Method)1 Counting (org.eclipse.microprofile.metrics.Counting)1 Gauge (org.eclipse.microprofile.metrics.Gauge)1 Metadata (org.eclipse.microprofile.metrics.Metadata)1 Metric (org.eclipse.microprofile.metrics.Metric)1 Tag (org.eclipse.microprofile.metrics.Tag)1 Timed (org.eclipse.microprofile.metrics.annotation.Timed)1