use of io.micrometer.core.instrument.distribution.HistogramSnapshot in project micrometer by micrometer-metrics.
the class ElasticMeterRegistry method writeSummary.
private Stream<String> writeSummary(DistributionSummary summary, long wallTime) {
HistogramSnapshot snap = summary.takeSnapshot();
Stream.Builder<String> stream = Stream.builder();
stream.add(index(summary, wallTime).field("count", summary.count()).field("sum", summary.totalAmount()).field("mean", summary.mean()).field("max", summary.max()).build());
return stream.build();
}
use of io.micrometer.core.instrument.distribution.HistogramSnapshot in project spring-boot by spring-projects.
the class RestTemplateMetricsConfigurationTests method autoTimeRequestsCanBeConfigured.
@Test
void autoTimeRequestsCanBeConfigured() {
this.contextRunner.withPropertyValues("management.metrics.web.client.request.autotime.enabled=true", "management.metrics.web.client.request.autotime.percentiles=0.5,0.7", "management.metrics.web.client.request.autotime.percentiles-histogram=true").run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context);
Timer timer = registry.get("http.client.requests").timer();
HistogramSnapshot snapshot = timer.takeSnapshot();
assertThat(snapshot.percentileValues()).hasSize(2);
assertThat(snapshot.percentileValues()[0].percentile()).isEqualTo(0.5);
assertThat(snapshot.percentileValues()[1].percentile()).isEqualTo(0.7);
});
}
use of io.micrometer.core.instrument.distribution.HistogramSnapshot in project pravega by pravega.
the class OpStatsLoggerImpl method toOpStatsData.
@Override
public OpStatsData toOpStatsData() {
long numFailed = fail.count();
long numSuccess = success.count();
HistogramSnapshot snapshot = success.takeSnapshot();
double avgLatencyMillis = snapshot.mean();
EnumMap<OpStatsData.Percentile, Long> percentileLongMap = new EnumMap<>(OpStatsData.Percentile.class);
// Only add entries into percentile map when percentile values are not missing from snapshot.
if (OpStatsData.PERCENTILE_ARRAY.length == snapshot.percentileValues().length) {
int index = 0;
for (OpStatsData.Percentile percent : OpStatsData.PERCENTILE_SET) {
percentileLongMap.put(percent, (long) snapshot.percentileValues()[index++].value());
}
}
return new OpStatsData(numSuccess, numFailed, avgLatencyMillis, percentileLongMap);
}
use of io.micrometer.core.instrument.distribution.HistogramSnapshot in project spring-boot by spring-projects.
the class WebMvcMetricsAutoConfigurationTests method autoTimeRequestsCanBeConfigured.
@Test
void autoTimeRequestsCanBeConfigured() {
this.contextRunner.withUserConfiguration(TestController.class).withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class, WebMvcAutoConfiguration.class)).withPropertyValues("management.metrics.web.server.request.autotime.enabled=true", "management.metrics.web.server.request.autotime.percentiles=0.5,0.7", "management.metrics.web.server.request.autotime.percentiles-histogram=true").run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context);
Timer timer = registry.get("http.server.requests").timer();
HistogramSnapshot snapshot = timer.takeSnapshot();
assertThat(snapshot.percentileValues()).hasSize(2);
assertThat(snapshot.percentileValues()[0].percentile()).isEqualTo(0.5);
assertThat(snapshot.percentileValues()[1].percentile()).isEqualTo(0.7);
});
}
use of io.micrometer.core.instrument.distribution.HistogramSnapshot in project spring-boot by spring-projects.
the class WebClientMetricsConfigurationTests method autoTimeRequestsCanBeConfigured.
@Test
void autoTimeRequestsCanBeConfigured() {
this.contextRunner.withPropertyValues("management.metrics.web.client.request.autotime.enabled=true", "management.metrics.web.client.request.autotime.percentiles=0.5,0.7", "management.metrics.web.client.request.autotime.percentiles-histogram=true").run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context);
Timer timer = registry.get("http.client.requests").timer();
HistogramSnapshot snapshot = timer.takeSnapshot();
assertThat(snapshot.percentileValues()).hasSize(2);
assertThat(snapshot.percentileValues()[0].percentile()).isEqualTo(0.5);
assertThat(snapshot.percentileValues()[1].percentile()).isEqualTo(0.7);
});
}
Aggregations