public LatencyMetric(T h) { Snapshot s = h.getSnapshot(); _min = h.min(); _max = h.max(); _mean = h.mean(); if (null != s) { _percentile95 = s.get95thPercentile(); _percentile99 = s.get99thPercentile(); _percentile999 = s.get999thPercentile(); } else { _percentile95 = -1; _percentile99 = -1; _percentile999 = -1; } _histogram = h; }
context.brokerId(), metricName, snapshot.get999thPercentile(), MetricsUtils.ATTRIBUTE_999TH_PERCENTILE); context.reporter().sendCruiseControlMetric(ccm);
context.brokerId(), metricName, snapshot.get999thPercentile(), MetricsUtils.ATTRIBUTE_999TH_PERCENTILE); context.reporter().sendCruiseControlMetric(ccm);
public double get999thPercentile() { return snapshot.get999thPercentile(); }
@Override public double get999thPercentile() { return metric.getSnapshot().get999thPercentile(); }
@Override public double get999thPercentile() { return metric.getSnapshot().get999thPercentile(); }
@Override public void processTimer(MetricName name, Timer timer, Context context) throws IOException { final PrintStream stream = context.getStream("# time,min,max,mean,median,stddev,95%,99%,99.9%"); final Snapshot snapshot = timer.getSnapshot(); stream.append(new StringBuilder() .append(timer.min()).append(',') .append(timer.max()).append(',') .append(timer.mean()).append(',') .append(snapshot.getMedian()).append(',') .append(timer.stdDev()).append(',') .append(snapshot.get95thPercentile()).append(',') .append(snapshot.get99thPercentile()).append(',') .append(snapshot.get999thPercentile()).toString()) .println(); stream.flush(); }
@Override public void processHistogram(MetricName name, Histogram histogram, Context context) throws IOException { final PrintStream stream = context.getStream("# time,min,max,mean,median,stddev,95%,99%,99.9%"); final Snapshot snapshot = histogram.getSnapshot(); stream.append(new StringBuilder() .append(histogram.min()).append(',') .append(histogram.max()).append(',') .append(histogram.mean()).append(',') .append(snapshot.getMedian()).append(',') .append(histogram.stdDev()).append(',') .append(snapshot.get95thPercentile()).append(',') .append(snapshot.get99thPercentile()).append(',') .append(snapshot.get999thPercentile()).toString()) .println(); stream.println(); stream.flush(); }
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); }
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()))); }
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"); }
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()); }
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())); }
@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); }