Search in sources :

Example 6 with DistributionSummary

use of io.micrometer.core.instrument.DistributionSummary in project spring-cloud-stream by spring-cloud.

the class DefaultDestinationPublishingMeterRegistry method publish.

protected void publish() {
    List<Metric<Number>> aggregatedMeters = new ArrayList<>();
    for (Meter meter : this.getMeters()) {
        if (meter instanceof Timer) {
            aggregatedMeters.add(toTimerMetric((Timer) meter));
        } else if (meter instanceof DistributionSummary) {
            aggregatedMeters.add(toSummaryMetric((DistributionSummary) meter));
        }
    }
    if (!aggregatedMeters.isEmpty()) {
        ApplicationMetrics metrics = new ApplicationMetrics(this.applicationProperties.getKey(), aggregatedMeters);
        metrics.setProperties(this.applicationProperties.getExportProperties());
        try {
            String jsonString = this.objectMapper.writeValueAsString(metrics);
            this.metricsConsumer.accept(jsonString);
        } catch (JsonProcessingException e) {
            logger.warn("Error producing JSON String representation metric data", e);
        }
    }
}
Also used : CumulativeDistributionSummary(io.micrometer.core.instrument.cumulative.CumulativeDistributionSummary) DistributionSummary(io.micrometer.core.instrument.DistributionSummary) LongTaskTimer(io.micrometer.core.instrument.LongTaskTimer) CumulativeTimer(io.micrometer.core.instrument.cumulative.CumulativeTimer) Timer(io.micrometer.core.instrument.Timer) FunctionTimer(io.micrometer.core.instrument.FunctionTimer) CumulativeFunctionTimer(io.micrometer.core.instrument.cumulative.CumulativeFunctionTimer) DefaultLongTaskTimer(io.micrometer.core.instrument.internal.DefaultLongTaskTimer) Meter(io.micrometer.core.instrument.Meter) DefaultMeter(io.micrometer.core.instrument.internal.DefaultMeter) ArrayList(java.util.ArrayList) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 7 with DistributionSummary

use of io.micrometer.core.instrument.DistributionSummary in project ddf by codice.

the class SourceMetricsImpl method updateLatencyMetric.

private static void updateLatencyMetric(Map.Entry<String, Serializable> property) {
    String key = property.getKey();
    String source = key.substring(METRICS_SOURCE_ELAPSED_PREFIX.length());
    DistributionSummary latency = LATENCY_SUMMARIES.computeIfAbsent(source, src -> DistributionSummary.builder(METRICS_PREFIX + "." + LATENCY_TYPE).description("Latency of catalog source requests.").tag(SOURCE_TAG, src).baseUnit("milliseconds").publishPercentiles(0.5, 0.95).register(Metrics.globalRegistry));
    latency.record((int) property.getValue());
}
Also used : DistributionSummary(io.micrometer.core.instrument.DistributionSummary)

Example 8 with DistributionSummary

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

the class DistributionSummaryTest method record.

@Test
@DisplayName("multiple recordings are maintained")
default void record(MeterRegistry registry) {
    DistributionSummary ds = registry.summary("my.summary");
    ds.record(10);
    clock(registry).add(step());
    ds.count();
    assertAll(() -> assertEquals(1L, ds.count()), () -> assertEquals(10L, ds.totalAmount()));
    ds.record(10);
    ds.record(10);
    clock(registry).add(step());
    assertAll(() -> assertTrue(ds.count() >= 2L), () -> assertTrue(ds.totalAmount() >= 20L));
}
Also used : DistributionSummary(io.micrometer.core.instrument.DistributionSummary) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 9 with DistributionSummary

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

the class DistributionSummaryTest method recordZero.

@Test
@DisplayName("record zero")
default void recordZero(MeterRegistry registry) {
    DistributionSummary ds = registry.summary("my.summary");
    ds.record(0);
    clock(registry).add(step());
    assertAll(() -> assertEquals(1L, 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 10 with DistributionSummary

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

the class SummariesTest method shouldIgnoreSummaryLabel.

@Test
public void shouldIgnoreSummaryLabel() {
    MeterRegistry registry = new SimpleMeterRegistry();
    BackendRegistries.registerMatchers(registry, Collections.singletonList(new Match().setLabel("address").setType(MatchType.REGEX).setValue(".*").setAlias("_")));
    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", "_").summary();
    assertThat(s.count()).isEqualTo(3);
    assertThat(s.totalAmount()).isEqualTo(23);
    s = registry.find("my_summary").tags("address", "addr1").summary();
    assertThat(s).isNull();
    s = registry.find("my_summary").tags("address", "addr2").summary();
    assertThat(s).isNull();
}
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)

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