use of io.micrometer.core.instrument.distribution.pause.ClockDriftPauseDetector in project micrometer by micrometer-metrics.
the class CompositeMeterRegistryTest method compositePauseDetectorConfigOverridesChild.
@Test
void compositePauseDetectorConfigOverridesChild() {
composite.add(simple);
CountDownLatch count = new CountDownLatch(1);
composite.config().pauseDetector(new ClockDriftPauseDetector(Duration.ofSeconds(1), Duration.ofSeconds(1)) {
@Override
public Duration getPauseThreshold() {
count.countDown();
return super.getPauseThreshold();
}
});
composite.timer("my.timer");
assertThat(count.getCount()).isEqualTo(0);
}
use of io.micrometer.core.instrument.distribution.pause.ClockDriftPauseDetector 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