use of io.vertx.micrometer.MicrometerMetricsOptions in project vertx-micrometer-metrics by vert-x3.
the class JmxMetricsITest method shouldReportJmx.
@Test
public void shouldReportJmx(TestContext context) throws Exception {
vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setJmxMetricsOptions(new VertxJmxMetricsOptions().setEnabled(true).setStep(1)).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);
}
use of io.vertx.micrometer.MicrometerMetricsOptions in project vertx-micrometer-metrics by vert-x3.
the class PrometheusMetricsITest method shouldStartEmbeddedServer.
@Test
public void shouldStartEmbeddedServer(TestContext context) {
vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true).setStartEmbeddedServer(true).setEmbeddedServerOptions(new HttpServerOptions().setPort(9090))).setEnabled(true)));
Async async = context.async();
tryConnect(vertx, context, 9090, "localhost", "/metrics", body -> {
context.verify(v -> assertThat(body).contains("vertx_http_server_connections{local=\"0.0.0.0:9090\",remote=\"_\",} 1.0"));
async.complete();
}, 0);
async.awaitSuccess(10000);
}
use of io.vertx.micrometer.MicrometerMetricsOptions in project vertx-micrometer-metrics by vert-x3.
the class PrometheusMetricsITest method shouldBindExistingServer.
@Test
public void shouldBindExistingServer(TestContext context) {
vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)).setEnabled(true)));
Router router = Router.router(vertx);
router.route("/custom").handler(routingContext -> {
PrometheusMeterRegistry prometheusRegistry = (PrometheusMeterRegistry) BackendRegistries.getDefaultNow();
String response = prometheusRegistry.scrape();
routingContext.response().end(response);
});
vertx.createHttpServer().requestHandler(router::accept).listen(8081);
Async async = context.async();
HttpClientRequest req = vertx.createHttpClient().get(8081, "localhost", "/custom").handler(res -> {
context.assertEquals(200, res.statusCode());
res.bodyHandler(body -> {
context.verify(v -> assertThat(body.toString()).contains("vertx_http_"));
async.complete();
});
});
req.end();
async.awaitSuccess(10000);
}
use of io.vertx.micrometer.MicrometerMetricsOptions in project vertx-micrometer-metrics by vert-x3.
the class PrometheusMetricsITest method shouldExcludeCategory.
@Test
public void shouldExcludeCategory(TestContext context) {
vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true).setStartEmbeddedServer(true).setEmbeddedServerOptions(new HttpServerOptions().setPort(9090))).addDisabledMetricsCategory(MetricsDomain.HTTP_SERVER).setEnabled(true)));
Async async = context.async();
tryConnect(vertx, context, 9090, "localhost", "/metrics", body -> {
context.verify(v -> assertThat(body).contains("vertx_http_client_connections{local=\"?\",remote=\"localhost:9090\",} 1.0").doesNotContain("vertx_http_server_connections{local=\"0.0.0.0:9090\",remote=\"_\",} 1.0"));
async.complete();
}, 0);
async.awaitSuccess(10000);
}
Aggregations