/** * Get a new instance of an interval histogram, which will include a stable, consistent view of all value * counts accumulated since the last interval histogram was taken. * <p> * Calling {@link DoubleRecorder#getIntervalHistogram()} will reset * the value counts, and start accumulating value counts for the next interval. * * @return a histogram containing the value counts accumulated since the last interval histogram was taken. */ public synchronized DoubleHistogram getIntervalHistogram() { return getIntervalHistogram(null); }
boolean enforeContainingInstance) { validateFitAsReplacementHistogram(histogramToRecycle, enforeContainingInstance); inactiveHistogram = (InternalConcurrentDoubleHistogram) histogramToRecycle; performIntervalSample(); DoubleHistogram sampledHistogram = inactiveHistogram;
/** * Reset any value counts accumulated thus far. */ @Override public synchronized void reset() { // the currently inactive histogram is reset each time we flip. So flipping twice resets both: performIntervalSample(); performIntervalSample(); }
public void record(double value) { rotate(); try { for (DoubleRecorder recorder : ringBuffer) { recorder.recordValue(value); } } finally { accumulatedHistogramStale = true; } }
private void accumulate() { currentHistogram().getIntervalHistogramInto(intervalHistogram); accumulatedHistogram.add(intervalHistogram); }
synchronized (this) { do { currentHistogram().reset(); if (++currentBucket >= ringBuffer.length) { currentBucket = 0;
public RollingHistogram(Clock clock, StatisticConfig statisticConfig) { this.clock = clock; this.statisticConfig = statisticConfig; int ageBuckets = (int) statisticConfig.getBuckets(); ringBuffer = new DoubleRecorder[ageBuckets]; for (int i = 0; i < ageBuckets; i++) { ringBuffer[i] = new DoubleRecorder(statisticConfig.getPercentilePrecision()); } this.currentBucket = 0; this.lastRotateTimestampMillis = clock.getCurrentTime(); this.durationBetweenRotatesMillis = statisticConfig.getTimeWindow().toMillis() / ageBuckets; intervalHistogram = new DoubleHistogram(statisticConfig.getPercentilePrecision()); accumulatedHistogram = new DoubleHistogram(statisticConfig.getPercentilePrecision()); }
/** * Place a copy of the value counts accumulated since accumulated (since the last interval histogram * was taken) into {@code targetHistogram}. * * Calling {@link DoubleRecorder#getIntervalHistogramInto}() will reset * the value counts, and start accumulating value counts for the next interval. * * @param targetHistogram the histogram into which the interval histogram's data should be copied */ public synchronized void getIntervalHistogramInto(DoubleHistogram targetHistogram) { performIntervalSample(); inactiveHistogram.copyInto(targetHistogram); }
boolean enforeContainingInstance) { validateFitAsReplacementHistogram(histogramToRecycle, enforeContainingInstance); inactiveHistogram = (InternalConcurrentDoubleHistogram) histogramToRecycle; performIntervalSample(); DoubleHistogram sampledHistogram = inactiveHistogram;
/** * Reset any value counts accumulated thus far. */ @Override public synchronized void reset() { // the currently inactive histogram is reset each time we flip. So flipping twice resets both: performIntervalSample(); performIntervalSample(); }
return getIntervalHistogram(histogramToRecycle, true);
/** * Place a copy of the value counts accumulated since accumulated (since the last interval histogram * was taken) into {@code targetHistogram}. * * Calling {@link DoubleRecorder#getIntervalHistogramInto}() will reset * the value counts, and start accumulating value counts for the next interval. * * @param targetHistogram the histogram into which the interval histogram's data should be copied */ public synchronized void getIntervalHistogramInto(DoubleHistogram targetHistogram) { performIntervalSample(); inactiveHistogram.copyInto(targetHistogram); }
/** * Get a new instance of an interval histogram, which will include a stable, consistent view of all value * counts accumulated since the last interval histogram was taken. * <p> * Calling {@link DoubleRecorder#getIntervalHistogram()} will reset * the value counts, and start accumulating value counts for the next interval. * * @return a histogram containing the value counts accumulated since the last interval histogram was taken. */ public synchronized DoubleHistogram getIntervalHistogram() { return getIntervalHistogram(null); }
return getIntervalHistogram(histogramToRecycle, true);