Search in sources :

Example 1 with GaugeImpl

use of fish.payara.microprofile.metrics.impl.GaugeImpl in project Payara by payara.

the class MetricsInterceptor method registerMetrics.

private <E extends Member & AnnotatedElement> void registerMetrics(Class<?> bean, E element, Object target) {
    MetricsResolver.Of<Counted> counted = resolver.counted(bean, element);
    if (counted.isPresent()) {
        registry.counter(counted.metadata());
    }
    MetricsResolver.Of<Metered> metered = resolver.metered(bean, element);
    if (metered.isPresent()) {
        registry.meter(metered.metadata());
    }
    MetricsResolver.Of<Timed> timed = resolver.timed(bean, element);
    if (timed.isPresent()) {
        registry.timer(timed.metadata());
    }
    if (element instanceof Method && element.isAnnotationPresent(org.eclipse.microprofile.metrics.annotation.Gauge.class)) {
        MetricsResolver.Of<Gauge> gauge = resolver.gauge(bean, (Method) element);
        if (gauge.isPresent()) {
            registry.register(gauge.metricName(), new GaugeImpl((Method) element, target), gauge.metadata());
        }
    }
}
Also used : Counted(org.eclipse.microprofile.metrics.annotation.Counted) GaugeImpl(fish.payara.microprofile.metrics.impl.GaugeImpl) Metered(org.eclipse.microprofile.metrics.annotation.Metered) Timed(org.eclipse.microprofile.metrics.annotation.Timed) MetricsResolver(fish.payara.microprofile.metrics.cdi.MetricsResolver) Method(java.lang.reflect.Method) Gauge(org.eclipse.microprofile.metrics.annotation.Gauge)

Aggregations

MetricsResolver (fish.payara.microprofile.metrics.cdi.MetricsResolver)1 GaugeImpl (fish.payara.microprofile.metrics.impl.GaugeImpl)1 Method (java.lang.reflect.Method)1 Counted (org.eclipse.microprofile.metrics.annotation.Counted)1 Gauge (org.eclipse.microprofile.metrics.annotation.Gauge)1 Metered (org.eclipse.microprofile.metrics.annotation.Metered)1 Timed (org.eclipse.microprofile.metrics.annotation.Timed)1