Search in sources :

Example 1 with VertxMetrics

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);
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) DummyVertxMetrics(io.vertx.core.metrics.impl.DummyVertxMetrics) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) VertxInternal(io.vertx.core.impl.VertxInternal) DummyVertxMetrics(io.vertx.core.metrics.impl.DummyVertxMetrics) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 2 with VertxMetrics

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;
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) EventBusMetrics(io.vertx.core.spi.metrics.EventBusMetrics) VertxOptions(io.vertx.core.VertxOptions) VertxMetricsFactory(io.vertx.core.spi.VertxMetricsFactory)

Example 3 with VertxMetrics

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());
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) Test(org.junit.Test)

Example 4 with VertxMetrics

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);
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) DummyVertxMetrics(io.vertx.core.metrics.impl.DummyVertxMetrics) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) VertxInternal(io.vertx.core.impl.VertxInternal) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 5 with VertxMetrics

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;
}
Also used : DummyVertxMetrics(io.vertx.core.metrics.impl.DummyVertxMetrics) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) VertxMetricsFactory(io.vertx.core.spi.VertxMetricsFactory)

Aggregations

VertxMetrics (io.vertx.core.spi.metrics.VertxMetrics)5 MetricsOptions (io.vertx.core.metrics.MetricsOptions)4 VertxOptions (io.vertx.core.VertxOptions)3 DummyVertxMetrics (io.vertx.core.metrics.impl.DummyVertxMetrics)3 Test (org.junit.Test)3 VertxInternal (io.vertx.core.impl.VertxInternal)2 VertxMetricsFactory (io.vertx.core.spi.VertxMetricsFactory)2 FakeVertxMetrics (io.vertx.test.fakemetrics.FakeVertxMetrics)2 EventBusMetrics (io.vertx.core.spi.metrics.EventBusMetrics)1