Search in sources :

Example 56 with MetricsOptions

use of io.vertx.core.metrics.MetricsOptions in project vert.x by eclipse.

the class VertxFactoryTest method testFactoryMetricsFactoryOverridesOptions.

@Test
public void testFactoryMetricsFactoryOverridesOptions() {
    FakeVertxMetrics metrics = new FakeVertxMetrics();
    MetricsOptions metricsOptions = new MetricsOptions().setEnabled(true).setFactory(options -> {
        throw new AssertionError();
    });
    VertxBuilder factory = new VertxBuilder(new VertxOptions().setMetricsOptions(metricsOptions));
    factory.metrics(metrics);
    factory.init();
    Vertx vertx = factory.vertx();
    assertSame(metrics, ((VertxInternal) vertx).metricsSPI());
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 57 with MetricsOptions

use of io.vertx.core.metrics.MetricsOptions in project vert.x by eclipse.

the class MetricsTest method getOptions.

@Override
protected VertxOptions getOptions() {
    VertxOptions options = super.getOptions();
    options.setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(new FakeMetricsFactory()));
    return options;
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions)

Example 58 with MetricsOptions

use of io.vertx.core.metrics.MetricsOptions in project vert.x by eclipse.

the class MetricsOptionsTest method testSetMetricsInstanceTakesPrecedenceOverServiceLoader.

@Test
public void testSetMetricsInstanceTakesPrecedenceOverServiceLoader() {
    DummyVertxMetrics metrics = DummyVertxMetrics.INSTANCE;
    vertx.close();
    VertxOptions options = new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(new SimpleVertxMetricsFactory<>(metrics)));
    vertx = createVertxLoadingMetricsFromMetaInf(options, "io.vertx.test.fakemetrics.FakeMetricsFactory");
    assertSame(metrics, ((VertxInternal) vertx).metricsSPI());
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) DummyVertxMetrics(io.vertx.core.metrics.impl.DummyVertxMetrics) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 59 with MetricsOptions

use of io.vertx.core.metrics.MetricsOptions in project vertx-micrometer-metrics by vert-x3.

the class VertxMetricsFactoryImpl method metrics.

@Override
public VertxMetrics metrics(VertxOptions vertxOptions) {
    MetricsOptions metricsOptions = vertxOptions.getMetricsOptions();
    MicrometerMetricsOptions options;
    if (metricsOptions instanceof MicrometerMetricsOptions) {
        options = (MicrometerMetricsOptions) metricsOptions;
    } else {
        options = new MicrometerMetricsOptions(metricsOptions.toJson());
    }
    BackendRegistry backendRegistry = BackendRegistries.setupBackend(options);
    VertxMetricsImpl metrics = new VertxMetricsImpl(options, backendRegistry);
    metrics.init();
    if (options.isJvmMetricsEnabled()) {
        new ClassLoaderMetrics().bindTo(backendRegistry.getMeterRegistry());
        new JvmMemoryMetrics().bindTo(backendRegistry.getMeterRegistry());
        new JvmGcMetrics().bindTo(backendRegistry.getMeterRegistry());
        new ProcessorMetrics().bindTo(backendRegistry.getMeterRegistry());
        new JvmThreadMetrics().bindTo(backendRegistry.getMeterRegistry());
    }
    return metrics;
}
Also used : BackendRegistry(io.vertx.micrometer.backends.BackendRegistry) MicrometerMetricsOptions(io.vertx.micrometer.MicrometerMetricsOptions) MetricsOptions(io.vertx.core.metrics.MetricsOptions) ClassLoaderMetrics(io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics) JvmThreadMetrics(io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics) ProcessorMetrics(io.micrometer.core.instrument.binder.system.ProcessorMetrics) JvmMemoryMetrics(io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics) MicrometerMetricsOptions(io.vertx.micrometer.MicrometerMetricsOptions) JvmGcMetrics(io.micrometer.core.instrument.binder.jvm.JvmGcMetrics)

Aggregations

MetricsOptions (io.vertx.core.metrics.MetricsOptions)59 Test (org.junit.Test)49 DummyVertxMetrics (io.vertx.core.metrics.impl.DummyVertxMetrics)32 VertxMetricsFactory (io.vertx.core.spi.VertxMetricsFactory)27 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)26 CountDownLatch (java.util.concurrent.CountDownLatch)25 AtomicReference (java.util.concurrent.atomic.AtomicReference)25 io.vertx.core (io.vertx.core)24 Buffer (io.vertx.core.buffer.Buffer)24 DatagramSocket (io.vertx.core.datagram.DatagramSocket)24 DatagramSocketOptions (io.vertx.core.datagram.DatagramSocketOptions)24 EventBus (io.vertx.core.eventbus.EventBus)24 MessageConsumer (io.vertx.core.eventbus.MessageConsumer)24 io.vertx.core.http (io.vertx.core.http)24 io.vertx.core.net (io.vertx.core.net)24 BiConsumer (java.util.function.BiConsumer)24 Function (java.util.function.Function)24 VertxOptions (io.vertx.core.VertxOptions)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 EventBusOptions (io.vertx.core.eventbus.EventBusOptions)12