/** * 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); }
/** * It appears latency is reported in micros. * Using {@link Recorder} to support concurrent updates to histogram. */ public void measure(int latencyInMicros) { histogram.recordValue(latencyInMicros); }
/** * Create a reservoir with a default recorder. This recorder should be suitable for most usage. */ public HdrHistogramResetOnSnapshotReservoir() { this(new Recorder(2)); }
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; }
if (now > warmupEndTime) { long latencyMicros = NANOSECONDS.toMicros(now - sendTime); recorder.recordValue(latencyMicros); cumulativeRecorder.recordValue(latencyMicros); double throughput = bytesSent.sumThenReset() / elapsed / 1024 / 1024 * 8; reportHistogram = recorder.getIntervalHistogram(reportHistogram);
/** * Create a reservoir with a default recorder. This recorder should be suitable for most usage. * * @param name the name to give to the reservoir, for logging purposes * @param significantDigits how many significant digits to track in the reservoir */ public DeltaHdrHistogramReservoir(String name, int significantDigits) { this.metricName = name; this.recorder = new Recorder(significantDigits); /* * 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(); lastHistogram = new Histogram(intervalHistogram.getNumberOfSignificantValueDigits()); }
recorder.recordValue(latencyMillis); cumulativeRecorder.recordValue(latencyMillis); double throughput = bytesReceived.sumThenReset() / elapsed * 8 / 1024 / 1024; reportHistogram = recorder.getIntervalHistogram(reportHistogram);
/** * 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(); }
@Override public void update(long value) { recorder.recordValue(value); }
private void initializeRecorder() { if (_recorder == null) { _recorder = new Recorder(LOWEST_DISCERNIBLE_VALUE, HIGHEST_TRACKABLE_VALUE, NUMBER_OF_FIGNIFICANT_VALUE_DIGITS); } }
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; }
return getIntervalHistogram(histogramToRecycle, true);
@Override public void update(long value) { recorder.recordValue(value); }
/** * Create a reservoir with a default recorder. This recorder should be suitable for most usage. */ public HdrHistogramReservoir() { this(new Recorder(2)); }
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; }
private synchronized void recordSafeValue(long batchAggregationTimeNano) { initializeRecorder(); _recorder.recordValue(batchAggregationTimeNano); }
private void initializeRecorder() { if (_recorder == null) { _recorder = new Recorder(LOWEST_DISCERNIBLE_VALUE, HIGHEST_TRACKABLE_VALUE, NUMBER_OF_FIGNIFICANT_VALUE_DIGITS); } }
/** * @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(); } }
private synchronized void recordSafeValue(int batchSize) { initializeRecorder(); _recorder.recordValue(batchSize); }
public OneMeasurementHdrHistogram(String name, Properties props) { super(name); percentiles = getPercentileValues(props.getProperty(PERCENTILES_PROPERTY, PERCENTILES_PROPERTY_DEFAULT)); verbose = Boolean.valueOf(props.getProperty(VERBOSE_PROPERTY, String.valueOf(false))); boolean shouldLog = Boolean.parseBoolean(props.getProperty("hdrhistogram.fileoutput", "false")); if (!shouldLog) { log = null; histogramLogWriter = null; } else { try { final String hdrOutputFilename = props.getProperty("hdrhistogram.output.path", "") + name + ".hdr"; log = new PrintStream(new FileOutputStream(hdrOutputFilename), false); } catch (FileNotFoundException e) { throw new RuntimeException("Failed to open hdr histogram output file", e); } histogramLogWriter = new HistogramLogWriter(log); histogramLogWriter.outputComment("[Logging for: " + name + "]"); histogramLogWriter.outputLogFormatVersion(); long now = System.currentTimeMillis(); histogramLogWriter.outputStartTime(now); histogramLogWriter.setBaseTime(now); histogramLogWriter.outputLegend(); } histogram = new Recorder(3); }