use of io.vertx.core.metrics.MetricsOptions in project vert.x by eclipse.
the class MetricsContextTest method testFactoryInCluster.
@Test
public void testFactoryInCluster() throws Exception {
AtomicReference<Thread> metricsThread = new AtomicReference<>();
AtomicReference<Context> metricsContext = new AtomicReference<>();
Thread testThread = Thread.currentThread();
VertxMetricsFactory factory = (vertx, options) -> {
metricsThread.set(Thread.currentThread());
metricsContext.set(Vertx.currentContext());
return DummyVertxMetrics.INSTANCE;
};
clusteredVertx(new VertxOptions().setClustered(true).setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(factory)), onSuccess(vertx -> {
assertSame(testThread, metricsThread.get());
assertNull(metricsContext.get());
testComplete();
}));
await();
}
use of io.vertx.core.metrics.MetricsOptions in project vert.x by eclipse.
the class MetricsContextTest method testFactory.
@Test
public void testFactory() throws Exception {
AtomicReference<Thread> metricsThread = new AtomicReference<>();
AtomicReference<Context> metricsContext = new AtomicReference<>();
VertxMetricsFactory factory = (vertx, options) -> {
metricsThread.set(Thread.currentThread());
metricsContext.set(Vertx.currentContext());
return DummyVertxMetrics.INSTANCE;
};
vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(factory)));
assertSame(Thread.currentThread(), metricsThread.get());
assertNull(metricsContext.get());
}
use of io.vertx.core.metrics.MetricsOptions in project vert.x by eclipse.
the class MetricsContextTest method testEventBusLifecycle.
@Test
public void testEventBusLifecycle() {
AtomicBoolean closeCalled = new AtomicBoolean();
VertxMetricsFactory factory = (vertx, options) -> new DummyVertxMetrics() {
@Override
public EventBusMetrics createMetrics(EventBus eventBus) {
return new DummyEventBusMetrics() {
@Override
public boolean isEnabled() {
return true;
}
@Override
public void close() {
closeCalled.set(true);
}
};
}
};
Vertx vertx = vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(factory)));
vertx.eventBus();
executeInVanillaThread(() -> {
vertx.close(onSuccess(v -> {
assertTrue(closeCalled.get());
testComplete();
}));
});
await();
}
use of io.vertx.core.metrics.MetricsOptions in project vert.x by eclipse.
the class MetricsOptionsTest method testOptions.
@Test
public void testOptions() {
MetricsOptions options = new MetricsOptions();
assertFalse(options.isEnabled());
assertEquals(options, options.setEnabled(true));
assertTrue(options.isEnabled());
}
use of io.vertx.core.metrics.MetricsOptions in project vert.x by eclipse.
the class MetricsOptionsTest method testSetMetricsInstance.
@Test
public void testSetMetricsInstance() {
DummyVertxMetrics metrics = DummyVertxMetrics.INSTANCE;
vertx.close();
vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(new SimpleVertxMetricsFactory<>(metrics))));
assertSame(metrics, ((VertxInternal) vertx).metricsSPI());
}
Aggregations