Search in sources :

Example 56 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.

the class CompositeMeterRegistryAutoConfigurationTests method registerWhenHasMultipleMeterRegistriesShouldAddPrimaryComposite.

@Test
void registerWhenHasMultipleMeterRegistriesShouldAddPrimaryComposite() {
    this.contextRunner.withUserConfiguration(MultipleMeterRegistriesConfig.class).run((context) -> {
        assertThat(context.getBeansOfType(MeterRegistry.class)).hasSize(3).containsKeys("meterRegistryOne", "meterRegistryTwo", COMPOSITE_NAME);
        MeterRegistry primary = context.getBean(MeterRegistry.class);
        assertThat(primary).isInstanceOf(CompositeMeterRegistry.class);
        assertThat(((CompositeMeterRegistry) primary).getRegistries()).hasSize(2);
        assertThat(primary.config().clock()).isNotNull();
    });
}
Also used : CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) Test(org.junit.jupiter.api.Test)

Example 57 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.

the class CompositeMeterRegistryAutoConfigurationTests method registerWhenHasMultipleRegistriesAndOneIsPrimaryShouldDoNothing.

@Test
void registerWhenHasMultipleRegistriesAndOneIsPrimaryShouldDoNothing() {
    this.contextRunner.withUserConfiguration(MultipleMeterRegistriesWithOnePrimaryConfig.class).run((context) -> {
        assertThat(context.getBeansOfType(MeterRegistry.class)).hasSize(2).containsKeys("meterRegistryOne", "meterRegistryTwo");
        MeterRegistry primary = context.getBean(MeterRegistry.class);
        assertThat(primary).isInstanceOf(TestMeterRegistry.class);
    });
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) Test(org.junit.jupiter.api.Test)

Example 58 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.

the class DiskSpaceMetricsBinderTests method diskSpaceMetricsWithSinglePath.

@Test
void diskSpaceMetricsWithSinglePath() {
    MeterRegistry meterRegistry = new SimpleMeterRegistry();
    File path = new File(".");
    DiskSpaceMetricsBinder metricsBinder = new DiskSpaceMetricsBinder(Collections.singletonList(path), Tags.empty());
    metricsBinder.bindTo(meterRegistry);
    Tags tags = Tags.of("path", path.getAbsolutePath());
    assertThat(meterRegistry.get("disk.free").tags(tags).gauge()).isNotNull();
    assertThat(meterRegistry.get("disk.total").tags(tags).gauge()).isNotNull();
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) File(java.io.File) Tags(io.micrometer.core.instrument.Tags) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 59 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.

the class DiskSpaceMetricsBinderTests method diskSpaceMetricsWithCustomTags.

@Test
void diskSpaceMetricsWithCustomTags() {
    MeterRegistry meterRegistry = new SimpleMeterRegistry();
    File path = new File(".");
    Tags customTags = Tags.of("foo", "bar");
    DiskSpaceMetricsBinder metricsBinder = new DiskSpaceMetricsBinder(Collections.singletonList(path), customTags);
    metricsBinder.bindTo(meterRegistry);
    Tags tags = Tags.of("path", path.getAbsolutePath(), "foo", "bar");
    assertThat(meterRegistry.get("disk.free").tags(tags).gauge()).isNotNull();
    assertThat(meterRegistry.get("disk.total").tags(tags).gauge()).isNotNull();
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) File(java.io.File) Tags(io.micrometer.core.instrument.Tags) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 60 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project snow-owl by b2ihealthcare.

the class RepositoryPlugin method preRun.

@Override
public void preRun(SnowOwlConfiguration configuration, Environment env) {
    if (env.isServer()) {
        LOG.debug("Initializing repository plugin.");
        final MeterRegistry registry = env.service(MeterRegistry.class);
        final IEventBus eventBus = env.service(IEventBus.class);
        // Add event bus based request metrics
        registerRequestMetrics(registry, eventBus);
        final IManagedContainer container = env.container();
        RpcUtil.getInitialServerSession(container).registerServiceLookup(env::service);
        Net4jUtil.prepareContainer(container);
        JVMUtil.prepareContainer(container);
        TCPUtil.prepareContainer(container);
        LifecycleUtil.activate(container);
        final HostAndPort hostAndPort = env.service(RepositoryConfiguration.class).getHostAndPort();
        // open port in server environments
        if (hostAndPort.getPort() > 0) {
            // Starts the TCP transport
            TCPUtil.getAcceptor(container, hostAndPort.toString());
            LOG.info("Listening on {} for connections", hostAndPort);
        }
        // Starts the JVM transport
        JVMUtil.getAcceptor(container, TransportClient.NET_4_J_CONNECTOR_NAME);
        final RepositoryManager repositoryManager = new DefaultRepositoryManager();
        env.services().registerService(RepositoryManager.class, repositoryManager);
        env.services().registerService(RepositoryContextProvider.class, repositoryManager);
        int numberOfWorkers = env.service(RepositoryConfiguration.class).getMaxThreads();
        initializeRequestSupport(env, numberOfWorkers);
        LOG.debug("Initialized repository plugin.");
    } else {
        LOG.debug("Snow Owl application is running in remote mode.");
    }
    if (env.isServer()) {
        try {
            connectSystemUser(env.container());
        } catch (SnowowlServiceException e) {
            throw new SnowowlRuntimeException(e);
        }
    }
}
Also used : HostAndPort(com.google.common.net.HostAndPort) IManagedContainer(org.eclipse.net4j.util.container.IManagedContainer) RepositoryManager(com.b2international.snowowl.core.RepositoryManager) SnowowlServiceException(com.b2international.snowowl.core.api.SnowowlServiceException) RepositoryConfiguration(com.b2international.snowowl.core.config.RepositoryConfiguration) IEventBus(com.b2international.snowowl.eventbus.IEventBus) SnowowlRuntimeException(com.b2international.snowowl.core.api.SnowowlRuntimeException) MeterRegistry(io.micrometer.core.instrument.MeterRegistry)

Aggregations

MeterRegistry (io.micrometer.core.instrument.MeterRegistry)136 Test (org.junit.jupiter.api.Test)83 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)60 CompositeMeterRegistry (io.micrometer.core.instrument.composite.CompositeMeterRegistry)17 Timer (io.micrometer.core.instrument.Timer)15 Test (org.junit.Test)15 PrometheusMeterRegistry (io.micrometer.prometheus.PrometheusMeterRegistry)12 Duration (java.time.Duration)11 ApplicationContextRunner (org.springframework.boot.test.context.runner.ApplicationContextRunner)10 HikariDataSource (com.zaxxer.hikari.HikariDataSource)9 DataSource (javax.sql.DataSource)9 DelegatingDataSource (org.springframework.jdbc.datasource.DelegatingDataSource)9 SampleConfig (io.micrometer.core.samples.utils.SampleConfig)8 Match (io.vertx.micrometer.Match)8 FunctionCounter (io.micrometer.core.instrument.FunctionCounter)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 Normal (cern.jet.random.Normal)6 MersenneTwister64 (cern.jet.random.engine.MersenneTwister64)6 RandomEngine (cern.jet.random.engine.RandomEngine)6 Gauge (io.micrometer.core.instrument.Gauge)6