Search in sources :

Example 16 with MetricRegistry

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

the class PrometheusExporter method getEntriesForScope.

private void getEntriesForScope(MetricRegistry.Type scope, StringBuilder sb) {
    MetricRegistry registry = MetricRegistryFactory.get(scope);
    Map<String, Metric> metricMap = registry.getMetrics();
    exposeEntries(scope, sb, registry, metricMap);
}
Also used : MetricRegistry(org.eclipse.microprofile.metrics.MetricRegistry) Metric(org.eclipse.microprofile.metrics.Metric)

Example 17 with MetricRegistry

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

the class PrometheusExporter method exportOneMetric.

@Override
public StringBuilder exportOneMetric(MetricRegistry.Type scope, String metricName) {
    MetricRegistry registry = MetricRegistryFactory.get(scope);
    Map<String, Metric> metricMap = registry.getMetrics();
    Metric m = metricMap.get(metricName);
    Map<String, Metric> outMap = new HashMap<>(1);
    outMap.put(metricName, m);
    StringBuilder sb = new StringBuilder();
    exposeEntries(scope, sb, registry, outMap);
    return sb;
}
Also used : HashMap(java.util.HashMap) MetricRegistry(org.eclipse.microprofile.metrics.MetricRegistry) Metric(org.eclipse.microprofile.metrics.Metric)

Example 18 with MetricRegistry

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

the class MetricCdiInjectionExtension method registerMetrics.

void registerMetrics(@Observes AfterDeploymentValidation adv, BeanManager manager) {
    // Produce and register custom metrics
    MetricRegistry registry = getReference(manager, MetricRegistry.class);
    MetricName name = getReference(manager, MetricName.class);
    for (Map.Entry<Bean<?>, AnnotatedMember<?>> bean : metrics.entrySet()) {
        if (// skip non @Default beans
        !bean.getKey().getQualifiers().contains(DEFAULT) || // skip producer methods with injection point metadata
        hasInjectionPointMetadata(bean.getValue())) {
            continue;
        }
        String metricName = name.of(bean.getValue());
        registry.register(metricName, getReference(manager, bean.getValue().getBaseType(), bean.getKey()));
    }
    // Let's clear the collected metric producers
    metrics.clear();
}
Also used : MetricRegistry(org.eclipse.microprofile.metrics.MetricRegistry) AnnotatedMember(javax.enterprise.inject.spi.AnnotatedMember) HashMap(java.util.HashMap) Map(java.util.Map) Bean(javax.enterprise.inject.spi.Bean)

Aggregations

MetricRegistry (org.eclipse.microprofile.metrics.MetricRegistry)18 Metadata (org.eclipse.microprofile.metrics.Metadata)7 HashMap (java.util.HashMap)5 Metric (org.eclipse.microprofile.metrics.Metric)5 Map (java.util.Map)3 MetricsService (fish.payara.microprofile.metrics.MetricsService)2 NoSuchMetricException (fish.payara.microprofile.metrics.exception.NoSuchMetricException)2 AnnotatedMember (javax.enterprise.inject.spi.AnnotatedMember)2 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 MetricRegistryImpl (fish.payara.microprofile.metrics.impl.MetricRegistryImpl)1 MBeanMetadata (fish.payara.microprofile.metrics.jmx.MBeanMetadata)1 MBeanMetadataHelper.registerMetadata (fish.payara.microprofile.metrics.jmx.MBeanMetadataHelper.registerMetadata)1 MonitoringDataCollector (fish.payara.monitoring.collect.MonitoringDataCollector)1 HttpString (io.undertow.util.HttpString)1 Bean (javax.enterprise.inject.spi.Bean)1 ProcessProducer (javax.enterprise.inject.spi.ProcessProducer)1 Producer (javax.enterprise.inject.spi.Producer)1 MetricID (org.eclipse.microprofile.metrics.MetricID)1