public boolean convertMetric(String name, int epochSecs, Distribution dist, OpenTsdbClient.MetricsBuffer buffer) { Tuple2<String, StringBuilder> nameAndTags = getNameAndTags(name); if (nameAndTags == null) { return false; } String statName = nameAndTags._1(); StringBuilder tags = nameAndTags._2().append(" ").append(getDefaultTags()); float p50 = dist.histogram().getPercentile(0.5); float p90 = dist.histogram().getPercentile(0.9); float p95 = dist.histogram().getPercentile(0.95); float p99 = dist.histogram().getPercentile(0.99); long max = dist.maximum(); long count = dist.count(); float avg = (float) dist.average(); buffer.addMetric(statName + ".p50", epochSecs, p50, tags.toString()); buffer.addMetric(statName + ".p90", epochSecs, p90, tags.toString()); buffer.addMetric(statName + ".p95", epochSecs, p95, tags.toString()); buffer.addMetric(statName + ".p99", epochSecs, p99, tags.toString()); buffer.addMetric(statName + ".max", epochSecs, max, tags.toString()); buffer.addMetric(statName + ".count", epochSecs, count, tags.toString()); buffer.addMetric(statName + ".avg", epochSecs, avg, tags.toString()); return true; }
@Override public OpStatsData toOpStatsData() { long numSuccess = successCounter.apply(); long numFailures = failureCounter.apply(); com.twitter.ostrich.stats.Distribution distribution = successMetric.apply(); com.twitter.ostrich.stats.Histogram histogram = distribution.histogram(); double avgLatency = distribution.average(); long[] percentiles = new long[PERCENTILES.length]; int i = 0; for (double percentile : PERCENTILES) { percentiles[i] = histogram.getPercentile(percentile); ++i; } return new OpStatsData(numSuccess, numFailures, avgLatency, percentiles); }
public boolean convertMetric(String name, int epochSecs, Distribution dist, OpenTsdbClient.MetricsBuffer buffer) { Tuple2<String, StringBuilder> nameAndTags = getNameAndTags(name); if (nameAndTags == null) { return false; } String statName = nameAndTags._1(); StringBuilder tags = nameAndTags._2().append(" ").append(getDefaultTags()); float p50 = dist.histogram().getPercentile(0.5); float p90 = dist.histogram().getPercentile(0.9); float p95 = dist.histogram().getPercentile(0.95); float p99 = dist.histogram().getPercentile(0.99); long max = dist.maximum(); long count = dist.count(); float avg = (float) dist.average(); buffer.addMetric(statName + ".p50", epochSecs, p50, tags.toString()); buffer.addMetric(statName + ".p90", epochSecs, p90, tags.toString()); buffer.addMetric(statName + ".p95", epochSecs, p95, tags.toString()); buffer.addMetric(statName + ".p99", epochSecs, p99, tags.toString()); buffer.addMetric(statName + ".max", epochSecs, max, tags.toString()); buffer.addMetric(statName + ".count", epochSecs, count, tags.toString()); buffer.addMetric(statName + ".avg", epochSecs, avg, tags.toString()); return true; }