use of io.vertx.core.spi.metrics.VertxMetrics in project vert.x by eclipse.
the class MetricsOptionsTest method testMetricsEnabledWithoutConfig.
@Test
public void testMetricsEnabledWithoutConfig() {
vertx.close();
vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true)));
VertxMetrics metrics = ((VertxInternal) vertx).metricsSPI();
assertNotNull(metrics);
assertTrue(metrics instanceof DummyVertxMetrics);
}
use of io.vertx.core.spi.metrics.VertxMetrics in project vert.x by eclipse.
the class EventBusRegistrationRaceTest method getOptions.
@Override
protected VertxOptions getOptions() {
VertxOptions options = super.getOptions();
options.setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(new VertxMetricsFactory() {
@Override
public VertxMetrics metrics(VertxOptions options) {
return new VertxMetrics() {
@Override
public EventBusMetrics<Void> createEventBusMetrics() {
return new EventBusMetrics<Void>() {
@Override
public void scheduleMessage(Void handler, boolean local) {
count.incrementAndGet();
}
@Override
public void messageDelivered(Void handler, boolean local) {
count.decrementAndGet();
}
@Override
public void discardMessage(Void handler, boolean local, Message<?> msg) {
count.decrementAndGet();
}
};
}
};
}
}));
return options;
}
use of io.vertx.core.spi.metrics.VertxMetrics in project java-chassis by ServiceComb.
the class TestDefaultVertxMetricsFactory method metrics.
@SuppressWarnings("deprecation")
@Test
public void metrics() {
MetricsOptions metricsOptions = factory.newOptions();
options.setMetricsOptions(metricsOptions);
VertxMetrics vertxMetrics = factory.metrics(options);
Assert.assertSame(factory, metricsOptions.getFactory());
Assert.assertTrue(metricsOptions.isEnabled());
Assert.assertSame(factory.getVertxMetrics(), vertxMetrics);
Assert.assertTrue(vertxMetrics.isMetricsEnabled());
}
use of io.vertx.core.spi.metrics.VertxMetrics in project vert.x by eclipse.
the class MetricsOptionsTest method testMetricsFromServiceLoader.
@Test
public void testMetricsFromServiceLoader() {
vertx.close();
VertxOptions options = new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true));
vertx = createVertxLoadingMetricsFromMetaInf(options, "io.vertx.test.fakemetrics.FakeMetricsFactory");
VertxMetrics metrics = ((VertxInternal) vertx).metricsSPI();
assertNotNull(metrics);
assertTrue(metrics instanceof FakeVertxMetrics);
}
use of io.vertx.core.spi.metrics.VertxMetrics in project vert.x by eclipse.
the class VertxImpl method initialiseMetrics.
private VertxMetrics initialiseMetrics(VertxOptions options) {
if (options.getMetricsOptions() != null && options.getMetricsOptions().isEnabled()) {
VertxMetricsFactory factory = options.getMetricsOptions().getFactory();
if (factory == null) {
factory = ServiceHelper.loadFactoryOrNull(VertxMetricsFactory.class);
if (factory == null) {
log.warn("Metrics has been set to enabled but no VertxMetricsFactory found on classpath");
}
}
if (factory != null) {
VertxMetrics metrics = factory.metrics(this, options);
Objects.requireNonNull(metrics, "The metric instance created from " + factory + " cannot be null");
return metrics;
}
}
return DummyVertxMetrics.INSTANCE;
}
Aggregations