Search in sources :

Example 1 with VertxJmxMetricsOptions

use of io.vertx.micrometer.VertxJmxMetricsOptions 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);
}
Also used : Async(io.vertx.ext.unit.Async) VertxOptions(io.vertx.core.VertxOptions) MicrometerMetricsOptions(io.vertx.micrometer.MicrometerMetricsOptions) VertxJmxMetricsOptions(io.vertx.micrometer.VertxJmxMetricsOptions) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

VertxOptions (io.vertx.core.VertxOptions)1 Async (io.vertx.ext.unit.Async)1 MicrometerMetricsOptions (io.vertx.micrometer.MicrometerMetricsOptions)1 VertxJmxMetricsOptions (io.vertx.micrometer.VertxJmxMetricsOptions)1 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 Test (org.junit.Test)1