Search in sources :

Example 21 with SimpleMeterRegistry

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

the class JvmMemoryMetricsTest method memoryMetrics.

@Test
void memoryMetrics() {
    MeterRegistry registry = new SimpleMeterRegistry();
    new JvmMemoryMetrics().bindTo(registry);
    assertJvmBufferMetrics(registry, "direct");
    assertJvmBufferMetrics(registry, "mapped");
    assertJvmMemoryMetrics(registry, "heap");
    assertJvmMemoryMetrics(registry, "nonheap");
}
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 22 with SimpleMeterRegistry

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

the class CompositeCounterTest method increment.

@Test
@Issue("#119")
void increment() {
    SimpleMeterRegistry simple = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());
    CompositeMeterRegistry registry = new CompositeMeterRegistry();
    registry.add(simple);
    registry.counter("counter").increment(2.0);
    assertThat(simple.get("counter").counter().count()).isEqualTo(2.0);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MockClock(io.micrometer.core.instrument.MockClock) Issue(io.micrometer.core.Issue) Test(org.junit.jupiter.api.Test)

Example 23 with SimpleMeterRegistry

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

the class MetricsRequestEventListenerTest method configure.

@Override
protected Application configure() {
    registry = new SimpleMeterRegistry();
    final MetricsApplicationEventListener listener = new MetricsApplicationEventListener(registry, new DefaultJerseyTagsProvider(), METRIC_NAME, true);
    final ResourceConfig config = new ResourceConfig();
    config.register(listener);
    config.register(TestResource.class);
    return config;
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 24 with SimpleMeterRegistry

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

the class DistributionSummaryTest method histogramsInStepMode.

@Test
void histogramsInStepMode() {
    MockClock clock = new MockClock();
    MeterRegistry registry = new SimpleMeterRegistry(new SimpleConfig() {

        @Override
        public String get(String key) {
            return null;
        }

        @Override
        public CountingMode mode() {
            return CountingMode.STEP;
        }
    }, clock);
    DistributionSummary summary = DistributionSummary.builder("my.summary").sla(1).register(registry);
    summary.record(1);
    assertThat(summary.takeSnapshot().histogramCounts()).containsExactly(new CountAtBucket(1, 1));
    clock.add(SimpleConfig.DEFAULT.step());
    assertThat(summary.takeSnapshot().histogramCounts()).containsExactly(new CountAtBucket(1, 0));
}
Also used : SimpleConfig(io.micrometer.core.instrument.simple.SimpleConfig) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) CountingMode(io.micrometer.core.instrument.simple.CountingMode) CountAtBucket(io.micrometer.core.instrument.distribution.CountAtBucket) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Test(org.junit.jupiter.api.Test)

Example 25 with SimpleMeterRegistry

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

the class MeterRegistryTest method histogramConfigTransformingMeterFilter.

@Test
void histogramConfigTransformingMeterFilter() {
    MeterRegistry registry = new SimpleMeterRegistry() {

        @Override
        protected Timer newTimer(@Nonnull Meter.Id id, DistributionStatisticConfig histogramConfig, PauseDetector pauseDetector) {
            assertThat(histogramConfig.isPublishingHistogram()).isTrue();
            return super.newTimer(id, histogramConfig, pauseDetector);
        }
    };
    registry.config().meterFilter(new MeterFilter() {

        @Override
        public DistributionStatisticConfig configure(Meter.Id mappedId, DistributionStatisticConfig config) {
            return DistributionStatisticConfig.builder().percentiles(0.95).percentilesHistogram(true).build().merge(config);
        }
    });
    registry.timer("my.timer");
}
Also used : MeterFilter(io.micrometer.core.instrument.config.MeterFilter) Nonnull(javax.annotation.Nonnull) PauseDetector(io.micrometer.core.instrument.distribution.pause.PauseDetector) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) DistributionStatisticConfig(io.micrometer.core.instrument.distribution.DistributionStatisticConfig) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Test(org.junit.jupiter.api.Test)

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