Search in sources :

Example 1 with PauseDetector

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");
}
Also used : MeterFilter(io.micrometer.core.instrument.config.MeterFilter) Nonnull(javax.annotation.Nonnull) PauseDetector(io.micrometer.core.instrument.distribution.pause.PauseDetector) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) DistributionStatisticConfig(io.micrometer.core.instrument.distribution.DistributionStatisticConfig) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Test(org.junit.jupiter.api.Test)

Example 2 with PauseDetector

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);
            }
        }
    });
}
Also used : Nullable(io.micrometer.core.lang.Nullable) PauseDetector(io.micrometer.core.instrument.distribution.pause.PauseDetector) io.micrometer.core.instrument.distribution(io.micrometer.core.instrument.distribution) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TimeCappedMovingAverageIntervalEstimator(org.LatencyUtils.TimeCappedMovingAverageIntervalEstimator) IntervalEstimator(org.LatencyUtils.IntervalEstimator) Callable(java.util.concurrent.Callable) ClockDriftPauseDetector(io.micrometer.core.instrument.distribution.pause.ClockDriftPauseDetector) Supplier(java.util.function.Supplier) SimplePauseDetector(org.LatencyUtils.SimplePauseDetector) TimeUnit(java.util.concurrent.TimeUnit) MeterEquivalence(io.micrometer.core.instrument.util.MeterEquivalence) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) NoPauseDetector(io.micrometer.core.instrument.distribution.pause.NoPauseDetector) TimeCappedMovingAverageIntervalEstimator(org.LatencyUtils.TimeCappedMovingAverageIntervalEstimator) NoPauseDetector(io.micrometer.core.instrument.distribution.pause.NoPauseDetector) ClockDriftPauseDetector(io.micrometer.core.instrument.distribution.pause.ClockDriftPauseDetector) SimplePauseDetector(org.LatencyUtils.SimplePauseDetector)

Aggregations

PauseDetector (io.micrometer.core.instrument.distribution.pause.PauseDetector)2 MeterFilter (io.micrometer.core.instrument.config.MeterFilter)1 io.micrometer.core.instrument.distribution (io.micrometer.core.instrument.distribution)1 DistributionStatisticConfig (io.micrometer.core.instrument.distribution.DistributionStatisticConfig)1 ClockDriftPauseDetector (io.micrometer.core.instrument.distribution.pause.ClockDriftPauseDetector)1 NoPauseDetector (io.micrometer.core.instrument.distribution.pause.NoPauseDetector)1 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 MeterEquivalence (io.micrometer.core.instrument.util.MeterEquivalence)1 Nullable (io.micrometer.core.lang.Nullable)1 Map (java.util.Map)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Callable (java.util.concurrent.Callable)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 TimeUnit (java.util.concurrent.TimeUnit)1 Supplier (java.util.function.Supplier)1 Nonnull (javax.annotation.Nonnull)1 IntervalEstimator (org.LatencyUtils.IntervalEstimator)1 SimplePauseDetector (org.LatencyUtils.SimplePauseDetector)1 TimeCappedMovingAverageIntervalEstimator (org.LatencyUtils.TimeCappedMovingAverageIntervalEstimator)1 Test (org.junit.jupiter.api.Test)1