Search in sources :

Example 16 with SimpleMeterRegistry

use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.

the class JvmThreadMetricsTest method threadMetrics.

@Test
void threadMetrics() {
    MeterRegistry registry = new SimpleMeterRegistry();
    new JvmThreadMetrics().bindTo(registry);
    assertThat(registry.get("jvm.threads.live").gauge().value()).isGreaterThan(0);
    assertThat(registry.get("jvm.threads.daemon").gauge().value()).isGreaterThan(0);
    assertThat(registry.get("jvm.threads.peak").gauge().value()).isGreaterThan(0);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 17 with SimpleMeterRegistry

use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.

the class ProcessorMetricsTest method cpuMetrics.

@Test
void cpuMetrics() {
    MeterRegistry registry = new SimpleMeterRegistry();
    new ProcessorMetrics().bindTo(registry);
    assertThat(registry.get("system.cpu.count").gauge().value()).isGreaterThan(0);
    if (System.getProperty("os.name").toLowerCase().contains("win")) {
        assertThat(registry.find("system.load.average.1m").gauge()).describedAs("Not present on windows").isNull();
    } else {
        assertThat(registry.get("system.load.average.1m").gauge().value()).isGreaterThanOrEqualTo(0);
    }
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 18 with SimpleMeterRegistry

use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.

the class ProcessorMetricsTest method hotspotCpuMetrics.

@Test
void hotspotCpuMetrics() {
    assumeTrue(classExists("com.sun.management.OperatingSystemMXBean"));
    MeterRegistry registry = new SimpleMeterRegistry();
    new ProcessorMetrics().bindTo(registry);
    assertThat(registry.get("system.cpu.usage").gauge().value()).isGreaterThanOrEqualTo(0);
    assertThat(registry.get("process.cpu.usage").gauge().value()).isGreaterThanOrEqualTo(0);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 19 with SimpleMeterRegistry

use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.

the class CompositeLongTaskTimerTest method mapIdsToEachLongTaskTimerInComposite.

@Test
void mapIdsToEachLongTaskTimerInComposite() {
    MockClock clock = new MockClock();
    MeterRegistry s1 = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock);
    LongTaskTimer anotherTimer = s1.more().longTaskTimer("long.task");
    LongTaskTimer.Sample anotherSample = anotherTimer.start();
    clock.add(10, TimeUnit.NANOSECONDS);
    CompositeMeterRegistry registry = new CompositeMeterRegistry(clock);
    registry.add(s1);
    LongTaskTimer longTaskTimer = registry.more().longTaskTimer("long.task");
    LongTaskTimer.Sample sample = longTaskTimer.start();
    clock.add(100, TimeUnit.NANOSECONDS);
    assertThat(anotherSample.stop()).isEqualTo(110);
    // if this fails, the composite is using a timer ID that overlaps with a separate timer in a member
    // of the composite rather than mapping the ID to a separate ID in the composite member.
    assertThat(sample.stop()).isEqualTo(100);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) LongTaskTimer(io.micrometer.core.instrument.LongTaskTimer) MockClock(io.micrometer.core.instrument.MockClock) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 20 with SimpleMeterRegistry

use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.

the class JettyStatisticsMetricsTest method setup.

@BeforeEach
void setup() {
    this.registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());
    this.handler = new StatisticsHandler();
    JettyStatisticsMetrics.monitor(registry, handler);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) StatisticsHandler(org.eclipse.jetty.server.handler.StatisticsHandler) MockClock(io.micrometer.core.instrument.MockClock) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)42 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)20 Test (org.junit.jupiter.api.Test)20 Test (org.junit.Test)18 Match (io.vertx.micrometer.Match)8 Timer (io.micrometer.core.instrument.Timer)6 LongTaskTimer (io.micrometer.core.instrument.LongTaskTimer)5 MockClock (io.micrometer.core.instrument.MockClock)5 Counter (io.micrometer.core.instrument.Counter)4 DistributionSummary (io.micrometer.core.instrument.DistributionSummary)4 Gauge (io.micrometer.core.instrument.Gauge)4 HystrixPropertiesCommandDefault (com.netflix.hystrix.strategy.properties.HystrixPropertiesCommandDefault)2 Issue (io.micrometer.core.Issue)2 Tag (io.micrometer.core.instrument.Tag)2 MeterFilter (io.micrometer.core.instrument.config.MeterFilter)2 CountAtBucket (io.micrometer.core.instrument.distribution.CountAtBucket)2 SimpleConfig (io.micrometer.core.instrument.simple.SimpleConfig)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 LongAdder (java.util.concurrent.atomic.LongAdder)2 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)2