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