use of io.micrometer.influx.InfluxMeterRegistry 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.influx.InfluxMeterRegistry 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.influx.InfluxMeterRegistry in project vertx-micrometer-metrics by vert-x3.
the class CustomMicrometerMetricsITest method shouldReportWithCompositeRegistry.
@Test
public void shouldReportWithCompositeRegistry(TestContext context) throws Exception {
// Mock an influxdb server
Async asyncInflux = context.async();
InfluxDbTestHelper.simulateInfluxServer(vertxForSimulatedServer, context, 8087, body -> {
try {
context.verify(w -> assertThat(body).contains("vertx_eventbus_handlers,address=test-eb,metric_type=gauge value=1"));
} finally {
asyncInflux.complete();
}
});
CompositeMeterRegistry myRegistry = new CompositeMeterRegistry();
myRegistry.add(new JmxMeterRegistry(s -> null, Clock.SYSTEM));
myRegistry.add(new InfluxMeterRegistry(new InfluxConfig() {
@Override
public String get(String s) {
return null;
}
@Override
public Duration step() {
return Duration.ofSeconds(1);
}
@Override
public String uri() {
return "http://localhost:8087";
}
@Override
public boolean autoCreateDb() {
return false;
}
}, Clock.SYSTEM));
vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setMicrometerRegistry(myRegistry).setRegistryName(REGITRY_NAME).addDisabledMetricsCategory(MetricsDomain.HTTP_SERVER).addDisabledMetricsCategory(MetricsDomain.NAMED_POOLS).addLabels(Label.EB_ADDRESS).setEnabled(true)));
// Send something on the eventbus and wait til it's received
Async asyncEB = context.async();
vertx.eventBus().consumer("test-eb", msg -> asyncEB.complete());
vertx.eventBus().publish("test-eb", "test message");
asyncEB.await(2000);
// Read MBean
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
assertThat(mbs.getDomains()).contains("metrics");
Number result = (Number) mbs.getAttribute(new ObjectName("metrics", "name", "vertxEventbusHandlers.address.test-eb"), "Value");
assertThat(result).isEqualTo(1d);
// Await influx
asyncInflux.awaitSuccess();
}
use of io.micrometer.influx.InfluxMeterRegistry 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.influx.InfluxMeterRegistry in project spring-boot by spring-projects.
the class InfluxMetricsExportAutoConfigurationTests method stopsMeterRegistryWhenContextIsClosed.
@Test
void stopsMeterRegistryWhenContextIsClosed() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
InfluxMeterRegistry registry = context.getBean(InfluxMeterRegistry.class);
assertThat(registry.isClosed()).isFalse();
context.close();
assertThat(registry.isClosed()).isTrue();
});
}
Aggregations