use of io.micrometer.core.instrument.distribution.pause.PauseDetector in project micrometer by micrometer-metrics.
the class MeterRegistryTest method histogramConfigTransformingMeterFilter.
@Test
void histogramConfigTransformingMeterFilter() {
MeterRegistry registry = new SimpleMeterRegistry() {
@Override
protected Timer newTimer(@Nonnull Meter.Id id, DistributionStatisticConfig histogramConfig, PauseDetector pauseDetector) {
assertThat(histogramConfig.isPublishingHistogram()).isTrue();
return super.newTimer(id, histogramConfig, pauseDetector);
}
};
registry.config().meterFilter(new MeterFilter() {
@Override
public DistributionStatisticConfig configure(Meter.Id mappedId, DistributionStatisticConfig config) {
return DistributionStatisticConfig.builder().percentiles(0.95).percentilesHistogram(true).build().merge(config);
}
});
registry.timer("my.timer");
}
use of io.micrometer.core.instrument.distribution.pause.PauseDetector in project micrometer by micrometer-metrics.
the class AbstractTimer method initPauseDetector.
private void initPauseDetector(PauseDetector pauseDetectorType) {
org.LatencyUtils.PauseDetector pauseDetector = requireNonNull(pauseDetectorCache.computeIfAbsent(pauseDetectorType, detector -> {
if (detector instanceof ClockDriftPauseDetector) {
ClockDriftPauseDetector clockDriftPauseDetector = (ClockDriftPauseDetector) detector;
return new SimplePauseDetector(clockDriftPauseDetector.getSleepInterval().toNanos(), clockDriftPauseDetector.getPauseThreshold().toNanos(), 1, false);
} else if (detector instanceof NoPauseDetector) {
return new NoopPauseDetector();
}
return new NoopPauseDetector();
}));
this.intervalEstimator = new TimeCappedMovingAverageIntervalEstimator(128, 10000000000L, pauseDetector);
pauseDetector.addListener((pauseLength, pauseEndTime) -> {
// System.out.println("Pause of length " + (pauseLength / 1e6) + "ms, end time " + pauseEndTime);
if (intervalEstimator != null) {
long estimatedInterval = intervalEstimator.getEstimatedInterval(pauseEndTime);
long observedLatencyMinbar = pauseLength - estimatedInterval;
if (observedLatencyMinbar >= estimatedInterval) {
recordValueWithExpectedInterval(observedLatencyMinbar, estimatedInterval);
}
}
});
}
Aggregations