Search in sources :

Example 16 with CollectorRegistry

use of io.prometheus.client.CollectorRegistry in project infrautils by opendaylight.

the class MetricsPrometheusExampleMain method main.

public static void main(String[] args) throws IOException {
    // see also OsgiWebInitializer
    CollectorRegistry collectorRegistry = new CollectorRegistrySingleton();
    PrometheusMetricProviderImpl metricProvider = new PrometheusMetricProviderImpl(collectorRegistry);
    MetricsExample metricsExample = new MetricsExample(metricProvider);
    metricsExample.init();
    HTTPServer server = new HTTPServer(new InetSocketAddress("localhost", 1234), collectorRegistry);
    System.in.read();
    server.stop();
    metricsExample.close();
    metricProvider.close();
}
Also used : HTTPServer(io.prometheus.client.exporter.HTTPServer) PrometheusMetricProviderImpl(org.opendaylight.infrautils.metrics.prometheus.impl.PrometheusMetricProviderImpl) InetSocketAddress(java.net.InetSocketAddress) CollectorRegistry(io.prometheus.client.CollectorRegistry) CollectorRegistrySingleton(org.opendaylight.infrautils.metrics.prometheus.impl.CollectorRegistrySingleton)

Example 17 with CollectorRegistry

use of io.prometheus.client.CollectorRegistry in project promregator by promregator.

the class AbstractMetricsEndpoint method setupOwnRequestScopedMetrics.

@PostConstruct
public void setupOwnRequestScopedMetrics() {
    this.requestRegistry = new CollectorRegistry();
    Builder builder = Gauge.build("promregator_up", "Indicator, whether the target of promregator is available");
    if (this.isLabelEnrichmentEnabled()) {
        builder = builder.labelNames(CFAllLabelsMetricFamilySamplesEnricher.getEnrichingLabelNames());
    } else {
        builder = builder.labelNames(NullMetricFamilySamplesEnricher.getEnrichingLabelNames());
    }
    this.up = builder.register(this.requestRegistry);
}
Also used : Builder(io.prometheus.client.Gauge.Builder) CollectorRegistry(io.prometheus.client.CollectorRegistry) PostConstruct(javax.annotation.PostConstruct)

Example 18 with CollectorRegistry

use of io.prometheus.client.CollectorRegistry in project promregator by promregator.

the class PromregatorApplication method collectorRegistry.

@Bean
public CollectorRegistry collectorRegistry() {
    CollectorRegistry cr = CollectorRegistry.defaultRegistry;
    DefaultExports.initialize();
    return cr;
}
Also used : CollectorRegistry(io.prometheus.client.CollectorRegistry) Bean(org.springframework.context.annotation.Bean)

Aggregations

CollectorRegistry (io.prometheus.client.CollectorRegistry)18 Test (org.junit.Test)7 Tuple (io.vavr.Tuple)3 HashMap (io.vavr.collection.HashMap)3 HashSet (io.vavr.collection.HashSet)3 Map (io.vavr.collection.Map)3 Collections.singleton (java.util.Collections.singleton)3 Collections.singletonList (java.util.Collections.singletonList)3 Supplier (java.util.function.Supplier)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 CircuitBreaker (io.github.resilience4j.circuitbreaker.CircuitBreaker)2 CircuitBreakerOpenException (io.github.resilience4j.circuitbreaker.CircuitBreakerOpenException)2 CircuitBreakerRegistry (io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry)2 InMemoryCircuitBreakerRegistry (io.github.resilience4j.circuitbreaker.internal.InMemoryCircuitBreakerRegistry)2 DropwizardExports (io.prometheus.client.dropwizard.DropwizardExports)2 HTTPServer (io.prometheus.client.exporter.HTTPServer)2 InetSocketAddress (java.net.InetSocketAddress)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 Provides (dagger.Provides)1 RateLimiter (io.github.resilience4j.ratelimiter.RateLimiter)1