Search in sources :

Example 6 with Counted

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

the class MetricsInterceptor method registerMetrics.

private <E extends Member & AnnotatedElement> void registerMetrics(Class<?> bean, E element) {
    MetricResolver.Of<Counted> counted = resolver.counted(bean, element);
    if (counted.isPresent()) {
        Counted t = counted.metricAnnotation();
        Metadata metadata = getMetadata(counted.metricName(), t.unit(), t.description(), t.displayName(), MetricType.COUNTER, t.tags());
        registry.counter(metadata);
    }
    MetricResolver.Of<Metered> metered = resolver.metered(bean, element);
    if (metered.isPresent()) {
        Metered t = metered.metricAnnotation();
        Metadata metadata = getMetadata(metered.metricName(), t.unit(), t.description(), t.displayName(), MetricType.METERED, t.tags());
        registry.meter(metadata);
    }
    MetricResolver.Of<Timed> timed = resolver.timed(bean, element);
    if (timed.isPresent()) {
        Timed t = timed.metricAnnotation();
        Metadata metadata = getMetadata(timed.metricName(), t.unit(), t.description(), t.displayName(), MetricType.TIMER, t.tags());
        registry.timer(metadata);
    }
}
Also used : Counted(org.eclipse.microprofile.metrics.annotation.Counted) Metered(org.eclipse.microprofile.metrics.annotation.Metered) Timed(org.eclipse.microprofile.metrics.annotation.Timed) Metadata(org.eclipse.microprofile.metrics.Metadata)

Aggregations

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