public double get98thPercentile() { return snapshot.get98thPercentile(); }
@Override public double get98thPercentile() { return metric.getSnapshot().get98thPercentile(); }
@Override public double get98thPercentile() { return metric.getSnapshot().get98thPercentile(); }
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()); }
@Override public void processHistogram(MetricName name, Histogram histogram, Long timestamp) { Map<String, Double> fields = new HashMap<String, Double>(); fields.put("Count", Double.valueOf(histogram.count())); fields.put("Max", histogram.max()); fields.put("Mean", histogram.mean()); fields.put("Min", histogram.min()); fields.put("StdDev", histogram.stdDev()); fields.put("Sum", histogram.sum()); Snapshot snapshot = histogram.getSnapshot(); fields.put("95thPercentile", snapshot.get95thPercentile()); fields.put("98thPercentile", snapshot.get98thPercentile()); fields.put("99thPercentile", snapshot.get99thPercentile()); fields.put("999thPercentile", snapshot.get999thPercentile()); publish(createMeasurement(name, timestamp, fixedTags, fields)); }
@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()))); }
@Override public ValueObject getValue(String key) { if ((key == null) || key.isEmpty() || "mean".equals(key)) { return ValueFactory.create(histogram.mean()); } else if ("max".equals(key)) { return ValueFactory.create(histogram.max()); } else if ("min".equals(key)) { return ValueFactory.create(histogram.min()); } else if ("stdev".equals(key)) { return ValueFactory.create(histogram.stdDev()); } else if ("median".equals(key)) { return ValueFactory.create(histogram.getSnapshot().getMedian()); } else if ("snapshot".equals(key)) { return ValueFactory.create(Arrays.toString(histogram.getSnapshot().getValues())); } else if ("75".equals(key)) { return ValueFactory.create(histogram.getSnapshot().get75thPercentile()); } else if ("95".equals(key)) { return ValueFactory.create(histogram.getSnapshot().get95thPercentile()); } else if ("98".equals(key)) { return ValueFactory.create(histogram.getSnapshot().get98thPercentile()); } else if ("99".equals(key)) { return ValueFactory.create(histogram.getSnapshot().get99thPercentile()); } else if ("999".equals(key)) { return ValueFactory.create(histogram.getSnapshot().get999thPercentile()); } else { throw new UnsupportedOperationException("Unhandled key: " + key); } }
@Test public void reportsHistogramValues() throws Exception { final Histogram histogram = mock(Histogram.class); when(histogram.count()).thenReturn(1L); when(histogram.max()).thenReturn(2.0); when(histogram.mean()).thenReturn(3.0); when(histogram.min()).thenReturn(4.0); when(histogram.stdDev()).thenReturn(5.0); final Snapshot snapshot = mock(Snapshot.class); when(snapshot.getMedian()).thenReturn(6.0); when(snapshot.get75thPercentile()).thenReturn(7.0); when(snapshot.get95thPercentile()).thenReturn(8.0); when(snapshot.get98thPercentile()).thenReturn(9.0); when(snapshot.get99thPercentile()).thenReturn(10.0); when(snapshot.get999thPercentile()).thenReturn(11.0); when(histogram.getSnapshot()).thenReturn(snapshot); reporter.processHistogram(name("histogram"), histogram, null); verify(output).send(decode("name = t.test.histogram.max, value = 2, group = histo, units = \"\"")); verify(output).send(decode("name = t.test.histogram.mean, value = 3.0, group = histo, units = \"\"")); verify(output).send(decode("name = t.test.histogram.min, value = 4, group = histo, units = \"\"")); verify(output).send(decode("name = t.test.histogram.stddev, value = 5.0, group = histo, units = \"\"")); verify(output).send(decode("name = t.test.histogram.median, value = 6.0, group = histo, units = \"\"")); verify(output).send(decode("name = t.test.histogram.75percentile, value = 7.0, group = histo, units = \"\"")); verify(output).send(decode("name = t.test.histogram.95percentile, value = 8.0, group = histo, units = \"\"")); verify(output).send(decode("name = t.test.histogram.98percentile, value = 9.0, group = histo, units = \"\"")); verify(output).send(decode("name = t.test.histogram.99percentile, value = 10.0, group = histo, units = \"\"")); verify(output).send(decode("name = t.test.histogram.999percentile, value = 11.0, group = histo, units = \"\"")); }
when(snapshot.get75thPercentile()).thenReturn((double) 600); when(snapshot.get95thPercentile()).thenReturn((double) 700); when(snapshot.get98thPercentile()).thenReturn((double) 800); when(snapshot.get99thPercentile()).thenReturn((double) 900); when(snapshot.get999thPercentile()).thenReturn((double) 1000);
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"); }
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); }
@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(); }