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);
}
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);
}
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()));
}
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);
}
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)));
}
Aggregations