Search in sources :

Example 1 with MetricsHelper

use of fish.payara.microprofile.metrics.cdi.MetricsHelper in project Payara by payara.

the class MetricCDIExtension method registerCustomMetrics.

private void registerCustomMetrics(@Observes AfterDeploymentValidation adv, BeanManager manager) {
    MetricsService metricsService = Globals.getDefaultBaseServiceLocator().getService(MetricsService.class);
    MetricRegistry registry = metricsService.getOrAddRegistry(metricsService.getApplicationName());
    MetricsHelper helper = getReference(manager, MetricsHelper.class);
    for (Map.Entry<Producer<?>, AnnotatedMember<?>> entry : metrics.entrySet()) {
        AnnotatedMember<?> annotatedMember = entry.getValue();
        Producer<?> prod = entry.getKey();
        if (hasInjectionPoints(annotatedMember)) {
            continue;
        }
        Metadata metadata = helper.metadataOf(annotatedMember);
        registry.register(metadata.getName(), (Metric) prod.produce(manager.createCreationalContext(null)), metadata);
    }
    metrics.clear();
}
Also used : MetricProducer(fish.payara.microprofile.metrics.cdi.producer.MetricProducer) ProcessProducer(javax.enterprise.inject.spi.ProcessProducer) Producer(javax.enterprise.inject.spi.Producer) MetricRegistryProducer(fish.payara.microprofile.metrics.cdi.producer.MetricRegistryProducer) MetricsService(fish.payara.microprofile.metrics.MetricsService) MetricRegistry(org.eclipse.microprofile.metrics.MetricRegistry) MetricsHelper(fish.payara.microprofile.metrics.cdi.MetricsHelper) AnnotatedMember(javax.enterprise.inject.spi.AnnotatedMember) Metadata(org.eclipse.microprofile.metrics.Metadata) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

MetricsService (fish.payara.microprofile.metrics.MetricsService)1 MetricsHelper (fish.payara.microprofile.metrics.cdi.MetricsHelper)1 MetricProducer (fish.payara.microprofile.metrics.cdi.producer.MetricProducer)1 MetricRegistryProducer (fish.payara.microprofile.metrics.cdi.producer.MetricRegistryProducer)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AnnotatedMember (javax.enterprise.inject.spi.AnnotatedMember)1 ProcessProducer (javax.enterprise.inject.spi.ProcessProducer)1 Producer (javax.enterprise.inject.spi.Producer)1 Metadata (org.eclipse.microprofile.metrics.Metadata)1 MetricRegistry (org.eclipse.microprofile.metrics.MetricRegistry)1