public double get75thPercentile() { return snapshot.get75thPercentile(); }
@Override public double get75thPercentile() { return metric.getSnapshot().get75thPercentile(); }
@Override public double get75thPercentile() { return metric.getSnapshot().get75thPercentile(); }
private static void writeSampling(Sampling metric, JsonGenerator json) throws IOException { final Snapshot snapshot = metric.getSnapshot(); json.writeNumberField("median", snapshot.getMedian()); json.writeNumberField("p75", snapshot.get75thPercentile()); json.writeNumberField("p95", snapshot.get95thPercentile()); json.writeNumberField("p98", snapshot.get98thPercentile()); json.writeNumberField("p99", snapshot.get99thPercentile()); json.writeNumberField("p999", snapshot.get999thPercentile()); }
@Override public void processHistogram(MetricName name, Histogram histogram, PrintStream stream) { final Snapshot snapshot = histogram.getSnapshot(); stream.printf(locale, " min = %2.2f\n", histogram.min()); stream.printf(locale, " max = %2.2f\n", histogram.max()); stream.printf(locale, " mean = %2.2f\n", histogram.mean()); stream.printf(locale, " stddev = %2.2f\n", histogram.stdDev()); stream.printf(locale, " median = %2.2f\n", snapshot.getMedian()); stream.printf(locale, " 75%% <= %2.2f\n", snapshot.get75thPercentile()); stream.printf(locale, " 95%% <= %2.2f\n", snapshot.get95thPercentile()); stream.printf(locale, " 98%% <= %2.2f\n", snapshot.get98thPercentile()); stream.printf(locale, " 99%% <= %2.2f\n", snapshot.get99thPercentile()); stream.printf(locale, " 99.9%% <= %2.2f\n", snapshot.get999thPercentile()); }
/** @return a summary of {@code hist}. */ public static String getHistogramReport(final Histogram hist) { Snapshot sn = hist.getSnapshot(); return ", mean=" + DOUBLE_FORMAT.format(hist.mean()) + ", min=" + DOUBLE_FORMAT.format(hist.min()) + ", max=" + DOUBLE_FORMAT.format(hist.max()) + ", stdDev=" + DOUBLE_FORMAT.format(hist.stdDev()) + ", 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 public void processTimer(MetricName name, Timer timer, PrintStream stream) { processMeter(name, timer, stream); final String durationUnit = abbrev(timer.durationUnit()); final Snapshot snapshot = timer.getSnapshot(); stream.printf(locale, " min = %2.2f%s\n", timer.min(), durationUnit); stream.printf(locale, " max = %2.2f%s\n", timer.max(), durationUnit); stream.printf(locale, " mean = %2.2f%s\n", timer.mean(), durationUnit); stream.printf(locale, " stddev = %2.2f%s\n", timer.stdDev(), durationUnit); stream.printf(locale, " median = %2.2f%s\n", snapshot.getMedian(), durationUnit); stream.printf(locale, " 75%% <= %2.2f%s\n", snapshot.get75thPercentile(), durationUnit); stream.printf(locale, " 95%% <= %2.2f%s\n", snapshot.get95thPercentile(), durationUnit); stream.printf(locale, " 98%% <= %2.2f%s\n", snapshot.get98thPercentile(), durationUnit); stream.printf(locale, " 99%% <= %2.2f%s\n", snapshot.get99thPercentile(), durationUnit); stream.printf(locale, " 99.9%% <= %2.2f%s\n", snapshot.get999thPercentile(), durationUnit); }
/** * Retrieve values for pre-defined stats (median/p75/p95/p99/p999) from a {@link Sampling} metric (e.g. histogram) * * @param sampling metric to retrieve stats from * @param convertNanToZero simulate {@link com.yammer.metrics.core.Histogram} histogram behavior when used with * {@link com.yammer.metrics.core.WavefrontHistogram} as input: * when "true", empty WavefrontHistogram reports zero values for all stats * @return sampling stats */ public static Map<String, Double> explodeSampling(Sampling sampling, boolean convertNanToZero) { final Snapshot snapshot = sampling.getSnapshot(); return ImmutableMap.<String, Double>builder() .put("median", sanitizeValue(snapshot.getMedian(), convertNanToZero)) .put("p75", sanitizeValue(snapshot.get75thPercentile(), convertNanToZero)) .put("p95", sanitizeValue(snapshot.get95thPercentile(), convertNanToZero)) .put("p99", sanitizeValue(snapshot.get99thPercentile(), convertNanToZero)) .put("p999", sanitizeValue(snapshot.get999thPercentile(), convertNanToZero)) .build(); }
private void addSnapshotDataObject(MetricName key, Histogram histogram, List<DataObject> dataObjectList) { Snapshot snapshot = histogram.getSnapshot(); dataObjectList.add(toDataObject(key, ".min", histogram.min())); dataObjectList.add(toDataObject(key, ".max", histogram.max())); dataObjectList.add(toDataObject(key, ".mean", histogram.mean())); dataObjectList.add(toDataObject(key, ".stddev", histogram.stdDev())); dataObjectList.add(toDataObject(key, ".median", snapshot.getMedian())); dataObjectList.add(toDataObject(key, ".75th", snapshot.get75thPercentile())); dataObjectList.add(toDataObject(key, ".95th", snapshot.get95thPercentile())); dataObjectList.add(toDataObject(key, ".98th", snapshot.get98thPercentile())); dataObjectList.add(toDataObject(key, ".99th", snapshot.get99thPercentile())); dataObjectList.add(toDataObject(key, ".99.9th", snapshot.get999thPercentile())); }
@Override protected void sendSampling(long epoch, String sanitizedName, Sampling metric) throws IOException { final Snapshot snapshot = metric.getSnapshot(); if (dimensions.contains(median)) sendFloat(epoch, sanitizedName, "median", snapshot.getMedian()); if (dimensions.contains(p75)) sendFloat(epoch, sanitizedName, "75percentile", snapshot.get75thPercentile()); if (dimensions.contains(p95)) sendFloat(epoch, sanitizedName, "95percentile", snapshot.get95thPercentile()); if (dimensions.contains(p98)) sendFloat(epoch, sanitizedName, "98percentile", snapshot.get98thPercentile()); if (dimensions.contains(p99)) sendFloat(epoch, sanitizedName, "99percentile", snapshot.get99thPercentile()); if (dimensions.contains(p999)) sendFloat(epoch, sanitizedName, "999percentile", snapshot.get999thPercentile()); }
private void addSnapshotDataObjectWithConvertDuration(MetricName key, Timer timer, List<DataObject> dataObjectList) { Snapshot snapshot = timer.getSnapshot(); dataObjectList.add(toDataObject(key, ".min", convertDuration(timer.min()))); dataObjectList.add(toDataObject(key, ".max", convertDuration(timer.max()))); dataObjectList.add(toDataObject(key, ".mean", convertDuration(timer.mean()))); dataObjectList.add(toDataObject(key, ".stddev", convertDuration(timer.stdDev()))); dataObjectList.add(toDataObject(key, ".median", convertDuration(snapshot.getMedian()))); dataObjectList.add(toDataObject(key, ".75th", convertDuration(snapshot.get75thPercentile()))); dataObjectList.add(toDataObject(key, ".95th", convertDuration(snapshot.get95thPercentile()))); dataObjectList.add(toDataObject(key, ".98th", convertDuration(snapshot.get98thPercentile()))); dataObjectList.add(toDataObject(key, ".99th", convertDuration(snapshot.get99thPercentile()))); dataObjectList.add(toDataObject(key, ".99.9th", convertDuration(snapshot.get999thPercentile()))); }
protected void sendSampling(long epoch, String sanitizedName, Sampling metric) throws IOException { final Snapshot snapshot = metric.getSnapshot(); sendFloat(epoch, sanitizedName, "median", snapshot.getMedian()); sendFloat(epoch, sanitizedName, "75percentile", snapshot.get75thPercentile()); sendFloat(epoch, sanitizedName, "95percentile", snapshot.get95thPercentile()); sendFloat(epoch, sanitizedName, "98percentile", snapshot.get98thPercentile()); sendFloat(epoch, sanitizedName, "99percentile", snapshot.get99thPercentile()); sendFloat(epoch, sanitizedName, "999percentile", snapshot.get999thPercentile()); }
private void pushSampling(MetricName name, Sampling sampling, Long epoch) { final Snapshot snapshot = sampling.getSnapshot(); pushGauge(name, snapshot.getMedian(), epoch, "median"); pushGauge(name, snapshot.get75thPercentile(), epoch, "75percentile"); pushGauge(name, snapshot.get95thPercentile(), epoch, "95percentile"); pushGauge(name, snapshot.get98thPercentile(), epoch, "98percentile"); pushGauge(name, snapshot.get99thPercentile(), epoch, "99percentile"); pushGauge(name, snapshot.get999thPercentile(), epoch, "999percentile"); }
@Override public void snapshot(MetricsRecordBuilder metricsRecordBuilder, boolean all) { if (all || changed()) { clearChanged(); final Snapshot s = sample.getSnapshot(); metricsRecordBuilder.addCounter(name + NUM_OPS_METRIC_NAME, "", count.get()); metricsRecordBuilder.addGauge(name + MIN_METRIC_NAME, "", getMin()); metricsRecordBuilder.addGauge(name + MAX_METRIC_NAME, "", getMax()); metricsRecordBuilder.addGauge(name + MEAN_METRIC_NAME, "", getMean()); metricsRecordBuilder.addGauge(name + MEDIAN_METRIC_NAME, "", s.getMedian()); metricsRecordBuilder.addGauge(name + SEVENTY_FIFTH_PERCENTILE_METRIC_NAME, "", s.get75thPercentile()); metricsRecordBuilder.addGauge(name + NINETY_FIFTH_PERCENTILE_METRIC_NAME, "", s.get95thPercentile()); metricsRecordBuilder.addGauge(name + NINETY_NINETH_PERCENTILE_METRIC_NAME, "", s.get99thPercentile()); } }
protected void sendSampling(String sanitizedName, Sampling metric) { final Snapshot snapshot = metric.getSnapshot(); sendToStatsD(sanitizedName + ".median", formatNumber(snapshot.getMedian())); sendToStatsD(sanitizedName + ".75percentile", formatNumber(snapshot.get75thPercentile())); sendToStatsD(sanitizedName + ".95percentile", formatNumber(snapshot.get95thPercentile())); sendToStatsD(sanitizedName + ".98percentile", formatNumber(snapshot.get98thPercentile())); sendToStatsD(sanitizedName + ".99percentile", formatNumber(snapshot.get99thPercentile())); sendToStatsD(sanitizedName + ".999percentile", formatNumber(snapshot.get999thPercentile())); }
public void updateSnapshotMetrics(MetricsRecordBuilder metricsRecordBuilder) { final Snapshot s = sample.getSnapshot(); metricsRecordBuilder.addCounter(Interns.info(name + NUM_OPS_METRIC_NAME, desc), count.get()); metricsRecordBuilder.addGauge(Interns.info(name + MIN_METRIC_NAME, desc), getMin()); metricsRecordBuilder.addGauge(Interns.info(name + MAX_METRIC_NAME, desc), getMax()); metricsRecordBuilder.addGauge(Interns.info(name + MEAN_METRIC_NAME, desc), getMean()); metricsRecordBuilder.addGauge(Interns.info(name + MEDIAN_METRIC_NAME, desc), s.getMedian()); metricsRecordBuilder.addGauge(Interns.info(name + SEVENTY_FIFTH_PERCENTILE_METRIC_NAME, desc), s.get75thPercentile()); metricsRecordBuilder.addGauge(Interns.info(name + NINETIETH_PERCENTILE_METRIC_NAME, desc), s.getValue(0.90)); metricsRecordBuilder.addGauge(Interns.info(name + NINETY_FIFTH_PERCENTILE_METRIC_NAME, desc), s.get95thPercentile()); metricsRecordBuilder.addGauge(Interns.info(name + NINETY_NINETH_PERCENTILE_METRIC_NAME, desc), s.get99thPercentile()); } }
@Override public void processHistogram(MetricName name, Histogram histogram, String x) throws IOException { final String sanitizedName = sanitizeName(name); final Snapshot snapshot = histogram.getSnapshot(); printDoubleField(sanitizedName + ".min", histogram.min(), "histo"); printDoubleField(sanitizedName + ".max", histogram.max(), "histo"); printDoubleField(sanitizedName + ".mean", histogram.mean(), "histo"); printDoubleField(sanitizedName + ".stddev", histogram.stdDev(), "histo"); printDoubleField(sanitizedName + ".median", snapshot.getMedian(), "histo"); printDoubleField(sanitizedName + ".75percentile", snapshot.get75thPercentile(), "histo"); printDoubleField(sanitizedName + ".95percentile", snapshot.get95thPercentile(), "histo"); printDoubleField(sanitizedName + ".98percentile", snapshot.get98thPercentile(), "histo"); printDoubleField(sanitizedName + ".99percentile", snapshot.get99thPercentile(), "histo"); printDoubleField(sanitizedName + ".999percentile", snapshot.get999thPercentile(), "histo"); }
@Override public void processTimer(MetricName name, Timer timer, String x) throws IOException { processMeter(name, timer, x); final String sanitizedName = sanitizeName(name); final Snapshot snapshot = timer.getSnapshot(); final String durationUnit = timer.durationUnit().name(); printDoubleField(sanitizedName + ".min", timer.min(), "timer", durationUnit); printDoubleField(sanitizedName + ".max", timer.max(), "timer", durationUnit); printDoubleField(sanitizedName + ".mean", timer.mean(), "timer", durationUnit); printDoubleField(sanitizedName + ".stddev", timer.stdDev(), "timer", durationUnit); printDoubleField(sanitizedName + ".median", snapshot.getMedian(), "timer", durationUnit); printDoubleField(sanitizedName + ".75percentile", snapshot.get75thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".95percentile", snapshot.get95thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".98percentile", snapshot.get98thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".99percentile", snapshot.get99thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".999percentile", snapshot.get999thPercentile(), "timer", durationUnit); }
@Override public void sendComplete() { // prep bundle format Bundle bundle = bundleFactory.createBundle(); BundleFormat tableFormat = bundle.getFormat(); ensureMinimumFieldCount(tableFormat, 2); AutoField label = new IndexField(0); AutoField value = new IndexField(1); // output Snapshot snapshot = histo.getSnapshot(); writeLine(label, value, bundle, ".5", snapshot.getMedian()); writeLine(label, value, bundleFactory.createBundle(), ".75", snapshot.get75thPercentile()); writeLine(label, value, bundleFactory.createBundle(), ".95", snapshot.get95thPercentile()); writeLine(label, value, bundleFactory.createBundle(), ".98", snapshot.get98thPercentile()); writeLine(label, value, bundleFactory.createBundle(), ".99", snapshot.get99thPercentile()); writeLine(label, value, bundleFactory.createBundle(), ".999", snapshot.get999thPercentile()); getNext().sendComplete(); }
@Override public void pushMetric(MetricsRecord mr) { final Snapshot s = this.getSnapshot(); mr.setMetric(getName() + NUM_OPS_METRIC_NAME, this.getCount()); mr.setMetric(getName() + MIN_METRIC_NAME, this.getMin()); mr.setMetric(getName() + MAX_METRIC_NAME, this.getMax()); mr.setMetric(getName() + MEAN_METRIC_NAME, (float) this.getMean()); mr.setMetric(getName() + STD_DEV_METRIC_NAME, (float) this.getStdDev()); mr.setMetric(getName() + MEDIAN_METRIC_NAME, (float) s.getMedian()); mr.setMetric(getName() + SEVENTY_FIFTH_PERCENTILE_METRIC_NAME, (float) s.get75thPercentile()); mr.setMetric(getName() + NINETY_FIFTH_PERCENTILE_METRIC_NAME, (float) s.get95thPercentile()); mr.setMetric(getName() + NINETY_NINETH_PERCENTILE_METRIC_NAME, (float) s.get99thPercentile()); } }