@Override public HistogramStatistics getStatistics() { return new DropwizardHistogramStatistics(dropwizardHistogram.getSnapshot()); } }
public Map<String, Object> values() { Map<String, Object> m = new LinkedHashMap<>(); m.putAll(counter.values()); m.put("p50_" + name, Math.round(this.histogram.getSnapshot().getMedian())); m.put("p95_" + name, Math.round(this.histogram.getSnapshot().get95thPercentile())); m.put("p99_" + name, Math.round(this.histogram.getSnapshot().get99thPercentile())); m.put("p999_" + name, Math.round(this.histogram.getSnapshot().get999thPercentile())); return m; } }
public static Map<String, Object> buildHistogramMap(Histogram h) { Map<String, Object> metrics = Maps.newHashMap(); if (h == null) { return metrics; } Map<String, Object> time = Maps.newHashMap(); time.put("max", h.getSnapshot().getMax()); time.put("min", h.getSnapshot().getMin()); time.put("mean", (long) h.getSnapshot().getMean()); time.put("95th_percentile", (long) h.getSnapshot().get95thPercentile()); time.put("98th_percentile", (long) h.getSnapshot().get98thPercentile()); time.put("99th_percentile", (long) h.getSnapshot().get99thPercentile()); time.put("std_dev", (long) h.getSnapshot().getStdDev()); metrics.put("time", time); metrics.put("count", h.getCount()); return metrics; }
public void writeValues(Histogram histogram, JsonGenerator jg) throws IOException { final Snapshot snapshot = histogram.getSnapshot(); jg.writeNumberField("count", histogram.getCount()); writeHistogramSnapshot(snapshot, jg); } }
@Override public int compare(Histogram o1, Histogram o2) { return Double.compare(o2.getSnapshot().getMean(), o1.getSnapshot().getMean()); } });
private void printHistogram(String name, Histogram histogram, int maxNameLength, StringBuilder sb) { sb.append(String.format("%" + maxNameLength + "s | ", name)); sb.append(formatCount(histogram.getCount())); printHistogramSnapshot(histogram.getSnapshot(), sb); sb.append('\n'); }
private void reportHistogram(JsonGenerator json, String name, Histogram histogram) throws IOException { Snapshot snapshot = histogram.getSnapshot(); json.writeFieldName(sanitize(name)); json.writeStartObject(); json.writeNumberField("count", histogram.getCount()); writeSnapshot(json, snapshot); json.writeEndObject(); }
@Override public Double getValue() { Snapshot snapshot = processedDurationHistogram.getSnapshot(); double meanProcessTime = snapshot.getMean(); int numProcessed = snapshot.getValues().length; return (numProcessed * meanProcessTime) / timeUnit.toMillis(window); } }
/** * Convert histogram snapshot. */ private SummaryMetricFamily fromHistogram(List<Map.Entry<MetricName, Histogram>> histogramsWithSameName) { final SummaryMetricFamily summaryMetricFamily = getSummaryMetricFamily(histogramsWithSameName, ""); for (Map.Entry<MetricName, Histogram> entry : histogramsWithSameName) { addSummaryMetric(summaryMetricFamily, entry.getKey(), entry.getValue().getSnapshot(), 1.0D, entry.getValue().getCount()); } return summaryMetricFamily; }
/** @return an abbreviated summary of {@code hist}. */ public static String getShortHistogramReport(final Histogram hist) { Snapshot sn = hist.getSnapshot(); return "mean=" + DOUBLE_FORMAT.format(sn.getMean()) + ", min=" + DOUBLE_FORMAT.format(sn.getMin()) + ", max=" + DOUBLE_FORMAT.format(sn.getMax()) + ", stdDev=" + DOUBLE_FORMAT.format(sn.getStdDev()) + ", 95th=" + DOUBLE_FORMAT.format(sn.get95thPercentile()) + ", 99th=" + DOUBLE_FORMAT.format(sn.get99thPercentile()); }
private void reportHistogram(List<Point> points, String prefix, String name, Histogram histogram, long timestamp) throws IOException { reportCounter(points, prefix, name, histogram, timestamp); reportSnapshot(points, prefix, name, histogram.getSnapshot(), timestamp, false); }
private void reportHistogram(String name, Histogram histogram) { final Metric metric = createMetric(name, "histogram"); reportHistogram(metric, histogram.getSnapshot()); }
private void reportHistogram(String prefix, String name, Histogram histogram, long timestamp) throws IOException { reportCounter(prefix, name, histogram, timestamp); reportSnapshot(prefix, name, histogram.getSnapshot(), timestamp, false); }
@TearDown(Level.Iteration) public void tearDown(Blackhole hole) { hole.consume(histogram.getSnapshot().getMedian()); hole.consume(histogramSlidingTimeWindow.getSnapshot().getMedian()); hole.consume(histogramUniform.getSnapshot().getMedian()); } }
private void reportHistograms(Map<MetricName, Histogram> histograms, long timestamp) { for (Map.Entry<MetricName, Histogram> entry : histograms.entrySet()) { final Histogram hist = entry.getValue(); final Snapshot snapshot = hist.getSnapshot(); reportLine(getInfluxDbLineProtocolString(entry.getKey()), "count=" + getIntegerValue(hist.getCount()) + "," + reportHistogramSnapshot(snapshot), timestamp); } }
/** @return a summary of {@code hist}. */ public static String getHistogramReport(final Histogram hist) { Snapshot sn = hist.getSnapshot(); return "mean=" + DOUBLE_FORMAT.format(sn.getMean()) + ", min=" + DOUBLE_FORMAT.format(sn.getMin()) + ", max=" + DOUBLE_FORMAT.format(sn.getMax()) + ", stdDev=" + DOUBLE_FORMAT.format(sn.getStdDev()) + ", 50th=" + DOUBLE_FORMAT.format(sn.getMedian()) + ", 75th=" + DOUBLE_FORMAT.format(sn.get75thPercentile()) + ", 95th=" + DOUBLE_FORMAT.format(sn.get95thPercentile()) + ", 99th=" + DOUBLE_FORMAT.format(sn.get99thPercentile()) + ", 99.9th=" + DOUBLE_FORMAT.format(sn.get999thPercentile()) + ", 99.99th=" + DOUBLE_FORMAT.format(sn.getValue(0.9999)) + ", 99.999th=" + DOUBLE_FORMAT.format(sn.getValue(0.99999)); }
@Override double apply(Histogram hist) { return hist.getSnapshot().getValue(0.9999); } };
@Override double apply(Histogram hist) { return hist.getSnapshot().getStdDev(); } },
public static Histogram histogram(long count, Snapshot snapshot) { final Histogram histogram = mock(Histogram.class); when(histogram.getCount()).thenReturn(count); when(histogram.getSnapshot()).thenReturn(snapshot); return histogram; }
public static Histogram metricSnapshot2Histogram(MetricSnapshot snapshot) { Histogram histogram; if (metricAccurateCal) { histogram = new Histogram(new ExponentiallyDecayingReservoir()); byte[] points = snapshot.get_points(); int len = snapshot.get_pointSize(); updateHistogramPoints(histogram, points, len); } else { histogram = new Histogram(new JAverageReservoir()); JAverageSnapshot averageSnapshot = (JAverageSnapshot) histogram.getSnapshot(); averageSnapshot.setMetricSnapshot(snapshot.deepCopy()); } return histogram; }