Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More 9s for percentiles #91

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Default to reporting 4 nines.
  • Loading branch information
cburroughs committed Oct 10, 2011
commit 1cf019866c5e0d0b0f52b90b610c79b5883c0284
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public static interface HistogramMBean extends MetricMBean {
public double get98thPercentile();
public double get99thPercentile();
public double get999thPercentile();
public double get9999thPercentile();
public List<?> values();
}

Expand Down Expand Up @@ -222,6 +223,11 @@ public double get999thPercentile() {
return metric.percentiles(0.999)[0];
}

@Override
public double get9999thPercentile() {
return metric.percentiles(0.9999)[0];
}

@Override
public List<?> values() {
return metric.values();
Expand Down Expand Up @@ -295,6 +301,11 @@ public double get999thPercentile() {
return metric.percentiles(0.999)[0];
}

@Override
public double get9999thPercentile() {
return metric.percentiles(0.9999)[0];
}

@Override
public List<?> values() {
return metric.values();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ private void printMetered(Metered meter, String name) {

private void printHistogram(HistogramMetric histogram, String name) {
final String sanitizedName = sanitizeName(name);
final double[] percentiles = histogram.percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999);
final double[] percentiles = histogram.percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999, 0.9999);

// TODO: what units make sense for histograms? should we add event type to the Histogram metric?
printDoubleField(sanitizedName + ".min", histogram.min(), "histo");
Expand All @@ -313,12 +313,13 @@ private void printHistogram(HistogramMetric histogram, String name) {
printDoubleField(sanitizedName + ".98percentile", percentiles[3], "histo");
printDoubleField(sanitizedName + ".99percentile", percentiles[4], "histo");
printDoubleField(sanitizedName + ".999percentile", percentiles[5], "histo");
printDoubleField(sanitizedName + ".9999percentile", percentiles[6], "histo");
}

private void printTimer(TimerMetric timer, String name) {
printMetered(timer, name);
final String sanitizedName = sanitizeName(name);
final double[] percentiles = timer.percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999);
final double[] percentiles = timer.percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999, 0.9999);
final String durationUnit = timer.durationUnit().name();
printDoubleField(sanitizedName + ".min", timer.min(), "timer", durationUnit);
printDoubleField(sanitizedName + ".max", timer.max(), "timer", durationUnit);
Expand All @@ -330,6 +331,7 @@ private void printTimer(TimerMetric timer, String name) {
printDoubleField(sanitizedName + ".98percentile", percentiles[3], "timer", durationUnit);
printDoubleField(sanitizedName + ".99percentile", percentiles[4], "timer", durationUnit);
printDoubleField(sanitizedName + ".999percentile", percentiles[5], "timer", durationUnit);
printDoubleField(sanitizedName + ".9999percentile", percentiles[6], "timer", durationUnit);
}

private void printDoubleField(String name, double value, String groupName, String units) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private void printMetered(Metered meter, String name, long epoch) {

private void printHistogram(HistogramMetric histogram, String name, long epoch) {
final String sanitizedName = sanitizeName(name);
final double[] percentiles = histogram.percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999);
final double[] percentiles = histogram.percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999, 0.9999);
final StringBuilder lines = new StringBuilder();
lines.append(String.format(locale, "%s%s.%s %2.2f %d\n", prefix, sanitizedName, "min", histogram.min(), epoch));
lines.append(String.format(locale, "%s%s.%s %2.2f %d\n", prefix, sanitizedName, "max", histogram.max(), epoch));
Expand All @@ -290,6 +290,7 @@ private void printHistogram(HistogramMetric histogram, String name, long epoch)
lines.append(String.format(locale, "%s%s.%s %2.2f %d\n", prefix, sanitizedName, "98percentile", percentiles[3], epoch));
lines.append(String.format(locale, "%s%s.%s %2.2f %d\n", prefix, sanitizedName, "99percentile", percentiles[4], epoch));
lines.append(String.format(locale, "%s%s.%s %2.2f %d\n", prefix, sanitizedName, "999percentile", percentiles[5], epoch));
lines.append(String.format(locale, "%s%s.%s %2.2f %d\n", prefix, sanitizedName, "9999percentile", percentiles[6], epoch));

sendToGraphite(lines.toString());
}
Expand All @@ -311,6 +312,7 @@ private void printTimer(TimerMetric timer, String name, long epoch) {
lines.append(String.format(locale, "%s%s.%s %2.2f %d\n", prefix, sanitizedName, "98percentile", percentiles[3], epoch));
lines.append(String.format(locale, "%s%s.%s %2.2f %d\n", prefix, sanitizedName, "99percentile", percentiles[4], epoch));
lines.append(String.format(locale, "%s%s.%s %2.2f %d\n", prefix, sanitizedName, "999percentile", percentiles[5], epoch));
lines.append(String.format(locale, "%s%s.%s %2.2f %d\n", prefix, sanitizedName, "9999percentile", percentiles[6], epoch));
sendToGraphite(lines.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,14 @@ private void writeHistogram(JsonGenerator json, HistogramMetric histogram, boole
json.writeNumberField("mean", histogram.mean());
json.writeNumberField("std_dev", histogram.stdDev());

final double[] percentiles = histogram.percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999);
final double[] percentiles = histogram.percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999, 0.9999);
json.writeNumberField("median", percentiles[0]);
json.writeNumberField("p75", percentiles[1]);
json.writeNumberField("p95", percentiles[2]);
json.writeNumberField("p98", percentiles[3]);
json.writeNumberField("p99", percentiles[4]);
json.writeNumberField("p999", percentiles[5]);
json.writeNumberField("p9999", percentiles[6]);

if (showFullSamples) {
json.writeObjectField("values", histogram.values());
Expand Down