use of org.LatencyUtils.TimeCappedMovingAverageIntervalEstimator 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