Search in sources :

Example 1 with DistributionSummary

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

the class SummariesTest method shouldAliasSummaryLabel.

@Test
public void shouldAliasSummaryLabel() {
    MeterRegistry registry = new SimpleMeterRegistry();
    BackendRegistries.registerMatchers(registry, Collections.singletonList(new Match().setLabel("address").setType(MatchType.REGEX).setValue("addr1").setAlias("1")));
    Summaries summaries = new Summaries("my_summary", "", registry, Label.ADDRESS);
    summaries.get("addr1").record(5);
    summaries.get("addr1").record(8);
    summaries.get("addr2").record(10);
    DistributionSummary s = registry.find("my_summary").tags("address", "1").summary();
    assertThat(s.count()).isEqualTo(2);
    assertThat(s.totalAmount()).isEqualTo(13);
    s = registry.find("my_summary").tags("address", "addr1").summary();
    assertThat(s).isNull();
    s = registry.find("my_summary").tags("address", "addr2").summary();
    assertThat(s.count()).isEqualTo(1);
    assertThat(s.totalAmount()).isEqualTo(10);
}
Also used : DistributionSummary(io.micrometer.core.instrument.DistributionSummary) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Match(io.vertx.micrometer.Match) Test(org.junit.Test)

Example 2 with DistributionSummary

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

the class SimpleMeterRegistryTest method slasOnlyNoPercentileHistogram.

@Issue("#370")
@Test
void slasOnlyNoPercentileHistogram() {
    DistributionSummary summary = DistributionSummary.builder("my.summary").sla(1, 2).register(registry);
    summary.record(1);
    Timer timer = Timer.builder("my.timer").sla(Duration.ofMillis(1)).register(registry);
    timer.record(1, TimeUnit.MILLISECONDS);
    Gauge summaryHist1 = registry.get("my.summary.histogram").tags("le", "1").gauge();
    Gauge summaryHist2 = registry.get("my.summary.histogram").tags("le", "2").gauge();
    Gauge timerHist = registry.get("my.timer.histogram").tags("le", "0.001").gauge();
    assertThat(summaryHist1.value()).isEqualTo(1);
    assertThat(summaryHist2.value()).isEqualTo(1);
    assertThat(timerHist.value()).isEqualTo(1);
    clock.add(SimpleConfig.DEFAULT.step());
    assertThat(summaryHist1.value()).isEqualTo(0);
    assertThat(summaryHist2.value()).isEqualTo(0);
    assertThat(timerHist.value()).isEqualTo(0);
}
Also used : DistributionSummary(io.micrometer.core.instrument.DistributionSummary) Timer(io.micrometer.core.instrument.Timer) Gauge(io.micrometer.core.instrument.Gauge) Issue(io.micrometer.core.Issue) Test(org.junit.jupiter.api.Test)

Example 3 with DistributionSummary

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

the class DistributionSummaryTest method recordNegative.

@Test
@DisplayName("negative quantities are ignored")
default void recordNegative(MeterRegistry registry) {
    DistributionSummary ds = registry.summary("my.summary");
    ds.record(-10);
    assertAll(() -> assertEquals(0, ds.count()), () -> assertEquals(0L, ds.totalAmount()));
}
Also used : DistributionSummary(io.micrometer.core.instrument.DistributionSummary) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with DistributionSummary

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

the class DistributionSummaryTest method scale.

@Test
@DisplayName("scale samples by a fixed factor")
default void scale(MeterRegistry registry) {
    DistributionSummary ds = DistributionSummary.builder("my.summary").scale(2.0).register(registry);
    ds.record(1);
    clock(registry).add(step());
    assertThat(ds.totalAmount()).isEqualTo(2.0);
}
Also used : DistributionSummary(io.micrometer.core.instrument.DistributionSummary) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with DistributionSummary

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

the class MicrometerAtlasTest method givenDistributionSummary_whenEnrichWithHistograms_thenDataAggregated.

@Test
public void givenDistributionSummary_whenEnrichWithHistograms_thenDataAggregated() {
    SimpleMeterRegistry registry = new SimpleMeterRegistry();
    DistributionSummary hist = DistributionSummary.builder("summary").histogram(Histogram.linear(0, 10, 5)).register(registry);
    hist.record(3);
    hist.record(8);
    hist.record(20);
    hist.record(40);
    hist.record(13);
    hist.record(26);
    Map<String, Integer> histograms = extractTagValueMap(registry, Type.Counter, 1.0);
    assertThat(histograms, allOf(hasEntry("bucket=0.0", 0), hasEntry("bucket=10.0", 2), hasEntry("bucket=20.0", 2), hasEntry("bucket=30.0", 1), hasEntry("bucket=40.0", 1), hasEntry("bucket=Infinity", 0)));
}
Also used : DistributionSummary(io.micrometer.core.instrument.DistributionSummary) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Test(org.junit.Test)

Aggregations

DistributionSummary (io.micrometer.core.instrument.DistributionSummary)11 Test (org.junit.jupiter.api.Test)5 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)4 Test (org.junit.Test)4 DisplayName (org.junit.jupiter.api.DisplayName)4 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)2 Timer (io.micrometer.core.instrument.Timer)2 Match (io.vertx.micrometer.Match)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Issue (io.micrometer.core.Issue)1 FunctionTimer (io.micrometer.core.instrument.FunctionTimer)1 Gauge (io.micrometer.core.instrument.Gauge)1 LongTaskTimer (io.micrometer.core.instrument.LongTaskTimer)1 Meter (io.micrometer.core.instrument.Meter)1 CumulativeDistributionSummary (io.micrometer.core.instrument.cumulative.CumulativeDistributionSummary)1 CumulativeFunctionTimer (io.micrometer.core.instrument.cumulative.CumulativeFunctionTimer)1 CumulativeTimer (io.micrometer.core.instrument.cumulative.CumulativeTimer)1 DefaultLongTaskTimer (io.micrometer.core.instrument.internal.DefaultLongTaskTimer)1 DefaultMeter (io.micrometer.core.instrument.internal.DefaultMeter)1 ArrayList (java.util.ArrayList)1