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();
}
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());
}
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());
}
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();
});
}
Aggregations