use of io.micrometer.influx.InfluxConfig in project spring-boot by spring-projects.
the class InfluxPropertiesTests method defaultValuesAreConsistent.
@Test
void defaultValuesAreConsistent() {
InfluxProperties properties = new InfluxProperties();
InfluxConfig config = InfluxConfig.DEFAULT;
assertStepRegistryDefaultValues(properties, config);
assertThat(properties.getDb()).isEqualTo(config.db());
assertThat(properties.getConsistency()).isEqualTo(config.consistency());
assertThat(properties.getUserName()).isEqualTo(config.userName());
assertThat(properties.getPassword()).isEqualTo(config.password());
assertThat(properties.getRetentionPolicy()).isEqualTo(config.retentionPolicy());
assertThat(properties.getRetentionDuration()).isEqualTo(config.retentionDuration());
assertThat(properties.getRetentionReplicationFactor()).isEqualTo(config.retentionReplicationFactor());
assertThat(properties.getRetentionShardDuration()).isEqualTo(config.retentionShardDuration());
assertThat(properties.getUri()).isEqualTo(config.uri());
assertThat(properties.isCompressed()).isEqualTo(config.compressed());
assertThat(properties.isAutoCreateDb()).isEqualTo(config.autoCreateDb());
assertThat(properties.getOrg()).isEqualTo(config.org());
assertThat(properties.getToken()).isEqualTo(config.token());
}
use of io.micrometer.influx.InfluxConfig 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.InfluxConfig in project pravega by pravega.
the class RegistryConfigUtilTest method testPrometheusConfig.
@Test
public void testPrometheusConfig() {
MetricsConfig appConfig = MetricsConfig.builder().with(MetricsConfig.OUTPUT_FREQUENCY, 40).with(MetricsConfig.METRICS_PREFIX, "prometheusPrefix").build();
InfluxConfig testConfig = RegistryConfigUtil.createInfluxConfig(appConfig);
assertTrue(40 == testConfig.step().getSeconds());
assertEquals("prometheusPrefix", testConfig.prefix());
assertNull(testConfig.get("Undefined Key"));
}
use of io.micrometer.influx.InfluxConfig in project pravega by pravega.
the class RegistryConfigUtilTest method testInfluxConfig.
@Test
public void testInfluxConfig() {
MetricsConfig appConfig = MetricsConfig.builder().with(MetricsConfig.OUTPUT_FREQUENCY, 39).with(MetricsConfig.METRICS_PREFIX, "influxPrefix").with(MetricsConfig.INFLUXDB_URI, "http://localhost:2375").with(MetricsConfig.INFLUXDB_NAME, "databaseName").with(MetricsConfig.INFLUXDB_USERNAME, "admin").with(MetricsConfig.INFLUXDB_PASSWORD, "changeme").with(MetricsConfig.INFLUXDB_RETENTION_POLICY, "2h").build();
InfluxConfig testConfig = RegistryConfigUtil.createInfluxConfig(appConfig);
assertTrue(39 == testConfig.step().getSeconds());
assertEquals("influxPrefix", testConfig.prefix());
assertEquals("http://localhost:2375", testConfig.uri());
assertEquals("databaseName", testConfig.db());
assertEquals("admin", testConfig.userName());
assertEquals("changeme", testConfig.password());
assertEquals("2h", testConfig.retentionPolicy());
assertNull(testConfig.get("Undefined Key"));
}
Aggregations