Search in sources :

Example 1 with StatsdMeterRegistry

use of io.micrometer.statsd.StatsdMeterRegistry in project pravega by pravega.

the class StatsProviderImpl method start.

@Synchronized
@Override
public void start() {
    log.info("Metrics prefix: {}", conf.getMetricsPrefix());
    if (conf.isEnableStatsDReporter()) {
        metrics.add(new StatsdMeterRegistry(RegistryConfigUtil.createStatsDConfig(conf), Clock.SYSTEM));
    }
    if (conf.isEnableInfluxDBReporter()) {
        metrics.add(new InfluxMeterRegistry(RegistryConfigUtil.createInfluxConfig(conf), Clock.SYSTEM));
    }
    if (conf.isEnablePrometheus()) {
        this.prometheusRegistry = new PrometheusMeterRegistry(RegistryConfigUtil.createPrometheusConfig(conf));
        metrics.add(prometheusRegistry);
    }
    Preconditions.checkArgument(metrics.getRegistries().size() != 0, "No meter register bound hence no storage for metrics!");
    init();
}
Also used : PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) StatsdMeterRegistry(io.micrometer.statsd.StatsdMeterRegistry) InfluxMeterRegistry(io.micrometer.influx.InfluxMeterRegistry) Synchronized(lombok.Synchronized)

Example 2 with StatsdMeterRegistry

use of io.micrometer.statsd.StatsdMeterRegistry in project pravega by pravega.

the class StatsProviderTest method testStatsProviderStartAndClose.

@Test
public void testStatsProviderStartAndClose() {
    // To improve test case isolation, create a new registry instead of using the global one.
    @Cleanup CompositeMeterRegistry localRegistry = new CompositeMeterRegistry();
    MetricsConfig appConfig = MetricsConfig.builder().with(MetricsConfig.ENABLE_STATISTICS, true).with(MetricsConfig.ENABLE_STATSD_REPORTER, true).with(MetricsConfig.ENABLE_INFLUXDB_REPORTER, false).build();
    @Cleanup StatsProvider statsProvider = new StatsProviderImpl(appConfig, localRegistry);
    statsProvider.start();
    for (MeterRegistry registry : localRegistry.getRegistries()) {
        assertFalse(registry instanceof InfluxMeterRegistry);
        assertTrue(registry instanceof StatsdMeterRegistry);
    }
    statsProvider.close();
    assertTrue(0 == localRegistry.getRegistries().size());
}
Also used : CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) StatsdMeterRegistry(io.micrometer.statsd.StatsdMeterRegistry) Cleanup(lombok.Cleanup) InfluxMeterRegistry(io.micrometer.influx.InfluxMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) StatsdMeterRegistry(io.micrometer.statsd.StatsdMeterRegistry) InfluxMeterRegistry(io.micrometer.influx.InfluxMeterRegistry) Test(org.junit.Test)

Example 3 with StatsdMeterRegistry

use of io.micrometer.statsd.StatsdMeterRegistry in project pravega by pravega.

the class StatsProviderTest method testStatsProviderStartWithoutExporting.

@Test
public void testStatsProviderStartWithoutExporting() {
    MetricsConfig appConfig = MetricsConfig.builder().with(MetricsConfig.ENABLE_STATISTICS, true).with(MetricsConfig.ENABLE_STATSD_REPORTER, true).with(MetricsConfig.ENABLE_INFLUXDB_REPORTER, true).build();
    @Cleanup CompositeMeterRegistry localRegistry = new CompositeMeterRegistry();
    @Cleanup StatsProvider statsProvider = new StatsProviderImpl(appConfig, localRegistry);
    statsProvider.startWithoutExporting();
    for (MeterRegistry registry : localRegistry.getRegistries()) {
        assertTrue(registry instanceof SimpleMeterRegistry);
        assertFalse(registry instanceof InfluxMeterRegistry);
        assertFalse(registry instanceof StatsdMeterRegistry);
    }
    statsProvider.close();
    assertTrue(0 == localRegistry.getRegistries().size());
}
Also used : CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) StatsdMeterRegistry(io.micrometer.statsd.StatsdMeterRegistry) Cleanup(lombok.Cleanup) InfluxMeterRegistry(io.micrometer.influx.InfluxMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) StatsdMeterRegistry(io.micrometer.statsd.StatsdMeterRegistry) InfluxMeterRegistry(io.micrometer.influx.InfluxMeterRegistry) Test(org.junit.Test)

Example 4 with StatsdMeterRegistry

use of io.micrometer.statsd.StatsdMeterRegistry in project spring-boot by spring-projects.

the class StatsdMetricsExportAutoConfigurationTests method stopsMeterRegistryWhenContextIsClosed.

@Test
void stopsMeterRegistryWhenContextIsClosed() {
    this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
        StatsdMeterRegistry registry = context.getBean(StatsdMeterRegistry.class);
        assertThat(registry.isClosed()).isFalse();
        context.close();
        assertThat(registry.isClosed()).isTrue();
    });
}
Also used : StatsdMeterRegistry(io.micrometer.statsd.StatsdMeterRegistry) Test(org.junit.jupiter.api.Test)

Aggregations

StatsdMeterRegistry (io.micrometer.statsd.StatsdMeterRegistry)4 InfluxMeterRegistry (io.micrometer.influx.InfluxMeterRegistry)3 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)2 CompositeMeterRegistry (io.micrometer.core.instrument.composite.CompositeMeterRegistry)2 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)2 Cleanup (lombok.Cleanup)2 Test (org.junit.Test)2 PrometheusMeterRegistry (io.micrometer.prometheus.PrometheusMeterRegistry)1 Synchronized (lombok.Synchronized)1 Test (org.junit.jupiter.api.Test)1