/** * 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 Recorder#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 Histogram getIntervalHistogram() { return getIntervalHistogram(null); }
/** * Create a reservoir with a user-specified recorder. * * @param recorder Recorder to use */ public HdrHistogramResetOnSnapshotReservoir(Recorder recorder) { this.recorder = recorder; /* * Start by flipping the recorder's interval histogram. * - it starts our counting at zero. Arguably this might be a bad thing if you wanted to feed in * a recorder that already had some measurements? But that seems crazy. * - intervalHistogram can be nonnull. */ intervalHistogram = recorder.getIntervalHistogram(); }
return getIntervalHistogram(histogramToRecycle, true);
private Histogram getIntervalHistogramAndAccumulate() { Histogram intervalHistogram = histogram.getIntervalHistogram(); // add this to the total time histogram. if (totalHistogram == null) { totalHistogram = intervalHistogram; } else { totalHistogram.add(intervalHistogram); } return intervalHistogram; }
/** * @return a copy of the accumulated state since the reservoir last had a snapshot */ @Nonnull private synchronized Histogram getDataSinceLastSnapshotAndReset() { intervalHistogram = recorder.getIntervalHistogram(intervalHistogram); return intervalHistogram.copy(); } }
/** * Allows consuming histogram and returning a result. * Histogram passed to the consumer includes stable, consistent view * of all values accumulated since last harvest. * This method is thread safe. * @param consumer consumer for a harvested histogram * @param <T> return type of a passed in function * @return a result of a passed in function */ public synchronized <T> T harvest(Function<Histogram, T> consumer) { initializeRecorder(); _recycle = _recorder.getIntervalHistogram(_recycle); return consumer.apply(_recycle); }
/** * Allows consuming histogram and returning a result. * Histogram passed to the consumer includes stable, consistent view * of all values accumulated since last harvest. * This method is thread safe. * @param consumer consumer for a harvested histogram * @param <T> return type of a passed in function * @return a result of a passed in function */ public synchronized <T> T harvest(Function<Histogram, T> consumer) { initializeRecorder(); _recycle = _recorder.getIntervalHistogram(_recycle); return consumer.apply(_recycle); } }
/** * @return a copy of the accumulated state since the reservoir was created */ @Nonnull private synchronized Histogram updateRunningTotals() { intervalHistogram = recorder.getIntervalHistogram(intervalHistogram); runningTotals.add(intervalHistogram); return runningTotals.copy(); } }
/** * Create a reservoir with a user-specified recorder. * * @param recorder Recorder to use */ public HdrHistogramReservoir(Recorder recorder) { this.recorder = recorder; /* * Start by flipping the recorder's interval histogram. * - it starts our counting at zero. Arguably this might be a bad thing if you wanted to feed in * a recorder that already had some measurements? But that seems crazy. * - intervalHistogram can be nonnull. * - it lets us figure out the number of significant digits to use in runningTotals. */ intervalHistogram = recorder.getIntervalHistogram(); runningTotals = new Histogram(intervalHistogram.getNumberOfSignificantValueDigits()); }
Histogram newHistogram = recorder.getIntervalHistogram(staleHistogram); future.set(newHistogram); return newHistogram;
public Recorder startTracker(Duration interval) { final Recorder histogram = new Recorder(3600000000000L, 3); Flux.interval(interval) .doOnNext( aLong -> { System.out.println("---- PING/ PONG HISTO ----"); histogram .getIntervalHistogram() .outputPercentileDistribution(System.out, 5, 1000.0, false); System.out.println("---- PING/ PONG HISTO ----"); }) .subscribe(); return histogram; }
/** * 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 Recorder#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 Histogram getIntervalHistogram() { return getIntervalHistogram(null); }
public ResetOnSnapshotAccumulator(Recorder recorder) { this.recorder = recorder; this.intervalHistogram = recorder.getIntervalHistogram(); }
Phase(Supplier<Recorder> recorderSupplier, long proposedInvalidationTimestamp) { this.recorder = recorderSupplier.get(); this.intervalHistogram = recorder.getIntervalHistogram(); this.totalsHistogram = intervalHistogram.copy(); this.proposedInvalidationTimestamp = proposedInvalidationTimestamp; }
/** * @return a copy of the accumulated state since the reservoir last had a snapshot */ @Nonnull private synchronized Histogram getDataSinceLastSnapshotAndReset() { intervalHistogram = recorder.getIntervalHistogram(intervalHistogram); return intervalHistogram.copy(); } }
/** * @return a copy of the accumulated state since the reservoir was created */ @Nonnull private synchronized Histogram updateRunningTotals() { intervalHistogram = recorder.getIntervalHistogram(intervalHistogram); runningTotals.add(intervalHistogram); return runningTotals.copy(); } }
/** * @return a copy of the accumulated state since the reservoir was created */ @Nonnull private synchronized Histogram updateRunningTotals() { intervalHistogram = recorder.getIntervalHistogram(intervalHistogram); runningTotals.add(intervalHistogram); return runningTotals.copy(); } }
public void updateStats() { topicLoadHistogram = topicLoadTimeRecorder.getIntervalHistogram(topicLoadHistogram); this.elapsedIntervalMs = (TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - topicLoadRecordStartTime); topicLoadRecordStartTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); this.meanTopicLoadMs = topicLoadHistogram.getMean(); this.medianTopicLoadMs = topicLoadHistogram.getValueAtPercentile(50); this.topicLoad95Ms = topicLoadHistogram.getValueAtPercentile(95); this.topicLoad99Ms = topicLoadHistogram.getValueAtPercentile(99); this.topicLoad999Ms = topicLoadHistogram.getValueAtPercentile(99.9); this.topicsLoad9999Ms = topicLoadHistogram.getValueAtPercentile(99.99); this.topicLoadCounts = topicLoadHistogram.getTotalCount(); }
public Recorder startTracker(Duration interval) { final Recorder histogram = new Recorder(3600000000000L, 3); Flux.interval(interval) .doOnNext(aLong -> { System.out.println("---- PING/ PONG HISTO ----"); histogram.getIntervalHistogram() .outputPercentileDistribution(System.out, 5, 1000.0, false); System.out.println("---- PING/ PONG HISTO ----"); }) .subscribe(); return histogram; }
private static void printAggregatedStats() { Histogram reportHistogram = cumulativeRecorder.getIntervalHistogram(); log.info( "Aggregated latency stats --- Latency: mean: {} ms - med: {} - 95pct: {} - 99pct: {} - 99.9pct: {} - 99.99pct: {} - 99.999pct: {} - Max: {}", dec.format(reportHistogram.getMean()), (long) reportHistogram.getValueAtPercentile(50), (long) reportHistogram.getValueAtPercentile(95), (long) reportHistogram.getValueAtPercentile(99), (long) reportHistogram.getValueAtPercentile(99.9), (long) reportHistogram.getValueAtPercentile(99.99), (long) reportHistogram.getValueAtPercentile(99.999), (long) reportHistogram.getMaxValue()); }