Search in sources :

Example 11 with SimpleMeterRegistry

use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project tutorials by eugenp.

the class MicrometerAtlasTest method givenTimer_whenEnrichWithTimescaleHistogram_thenTimeScaleDataCollected.

@Test
public void givenTimer_whenEnrichWithTimescaleHistogram_thenTimeScaleDataCollected() {
    SimpleMeterRegistry registry = new SimpleMeterRegistry();
    Timer timer = Timer.builder("timer").histogram(Histogram.linearTime(TimeUnit.MILLISECONDS, 0, 200, 3)).register(registry);
    timer.record(1000, TimeUnit.MILLISECONDS);
    timer.record(23, TimeUnit.MILLISECONDS);
    timer.record(450, TimeUnit.MILLISECONDS);
    timer.record(341, TimeUnit.MILLISECONDS);
    timer.record(500, TimeUnit.MILLISECONDS);
    Map<String, Integer> histograms = extractTagValueMap(registry, Type.Counter, 1.0);
    assertThat(histograms, allOf(hasEntry("bucket=0.0", 0), hasEntry("bucket=2.0E8", 1), hasEntry("bucket=4.0E8", 1), hasEntry("bucket=Infinity", 3)));
}
Also used : LongTaskTimer(io.micrometer.core.instrument.LongTaskTimer) Timer(io.micrometer.core.instrument.Timer) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Test(org.junit.Test)

Example 12 with SimpleMeterRegistry

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

the class TimedAspectTest method timeMethod.

@Test
void timeMethod() {
    MeterRegistry registry = new SimpleMeterRegistry();
    AspectJProxyFactory pf = new AspectJProxyFactory(new TimedService());
    pf.addAspect(new TimedAspect(registry));
    TimedService service = pf.getProxy();
    service.call();
    assertThat(registry.get("call").tag("class", "io.micrometer.core.aop.TimedAspectTest$TimedService").tag("method", "call").tag("extra", "tag").timer().count()).isEqualTo(1);
}
Also used : AspectJProxyFactory(org.springframework.aop.aspectj.annotation.AspectJProxyFactory) 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 13 with SimpleMeterRegistry

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

the class MicrometerMetricsPublisherCommandTest method testOpenCircuit.

@Disabled
@Test
void testOpenCircuit() {
    HystrixCommandKey key = HystrixCommandKey.Factory.asKey("MicrometerCOMMAND-B");
    HystrixCommandProperties properties = new HystrixPropertiesCommandDefault(key, propertiesSetter.withCircuitBreakerForceOpen(true));
    HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(key, groupKey, properties);
    HystrixCircuitBreaker circuitBreaker = HystrixCircuitBreaker.Factory.getInstance(key, groupKey, properties, metrics);
    SimpleMeterRegistry registry = new SimpleMeterRegistry();
    MicrometerMetricsPublisherCommand metricsPublisherCommand = new MicrometerMetricsPublisherCommand(registry, key, groupKey, metrics, circuitBreaker, properties);
    metricsPublisherCommand.initialize();
    new SuccessCommand(key).execute();
    new SuccessCommand(key).execute();
    new TimeoutCommand(key).execute();
    new FailureCommand(key).execute();
    new FailureCommand(key).execute();
    new SuccessCommand(key).execute();
    Iterable<Tag> tags = Tags.of("group", groupKey.name(), "key", key.name());
    assertExecutionMetric(registry, "short_circuited", 6.0);
    assertThat(registry.get("hystrix.execution").tags(tags).tags("event", "success").functionCounter().count()).isEqualTo(0.0);
    assertThat(registry.get("hystrix.execution").tags(tags).tags("event", "timeout").functionCounter().count()).isEqualTo(0.0);
    assertThat(registry.get("hystrix.execution").tags(tags).tags("event", "failure").functionCounter().count()).isEqualTo(0.0);
    assertThat(registry.get("hystrix.fallback").tags(tags).tags("event", "fallback_success").functionCounter().count()).isEqualTo(6.0);
    assertThat(registry.get("hystrix.circuit.breaker.open").tags(tags).gauge().value()).isEqualTo(1.0);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Tag(io.micrometer.core.instrument.Tag) HystrixPropertiesCommandDefault(com.netflix.hystrix.strategy.properties.HystrixPropertiesCommandDefault) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 14 with SimpleMeterRegistry

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

the class CompositeMeterRegistryTest method castingFunctionCounter.

@Issue("#255")
@Test
void castingFunctionCounter() {
    SimpleMeterRegistry registry = new SimpleMeterRegistry();
    CompositeMeterRegistry compositeMeterRegistry = new CompositeMeterRegistry();
    FunctionCounter.builder("foo", 1L, x -> x).register(compositeMeterRegistry);
    compositeMeterRegistry.add(registry);
}
Also used : MeterFilter(io.micrometer.core.instrument.config.MeterFilter) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Issue(io.micrometer.core.Issue) Collections.emptyList(java.util.Collections.emptyList) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SimpleConfig(io.micrometer.core.instrument.simple.SimpleConfig) ClockDriftPauseDetector(io.micrometer.core.instrument.distribution.pause.ClockDriftPauseDetector) DisplayName(org.junit.jupiter.api.DisplayName) Test(org.junit.jupiter.api.Test) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NamingConvention(io.micrometer.core.instrument.config.NamingConvention) Duration(java.time.Duration) io.micrometer.core.instrument(io.micrometer.core.instrument) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Issue(io.micrometer.core.Issue) Test(org.junit.jupiter.api.Test)

Example 15 with SimpleMeterRegistry

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

the class HistogramGaugesTest method snapshotRollsOverAfterEveryPublish.

@Test
void snapshotRollsOverAfterEveryPublish() {
    MeterRegistry registry = new SimpleMeterRegistry();
    Timer timer = Timer.builder("my.timer").sla(Duration.ofMillis(1)).register(registry);
    HistogramGauges gauges = HistogramGauges.registerWithCommonFormat(timer, registry);
    timer.record(1, TimeUnit.MILLISECONDS);
    assertThat(registry.get("my.timer.histogram").gauge().value()).isEqualTo(1);
    assertThat(gauges.polledGaugesLatch.getCount()).isEqualTo(0);
}
Also used : Timer(io.micrometer.core.instrument.Timer) 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)

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