@Managed public double getPercentile(double percentile) { if (percentile < 0 || percentile > 1) { throw new IllegalArgumentException("percentile must be between 0 and 1"); } return sample.percentiles(percentile)[0]; }
@Managed public double getMax() { List<Long> values = sample.values(); if (!values.isEmpty()) { return Collections.max(values); } return Double.NaN; }
@Managed public double getMean() { List<Long> values = sample.values(); if (!values.isEmpty()) { long sum = 0; for (long value : values) { sum += value; } return sum * 1.0 / values.size(); } return Double.NaN; }
@Managed(description = "99th Percentile Measurement") public double getTP99() { return sample.percentiles(0.99)[0]; }
@Managed(description = "50th Percentile Measurement") public double getTP50() { return sample.percentiles(0.5)[0]; }
public void addValue(Duration duration) { sample.update(duration.toMillis()); sum.addAndGet(duration.toMillis()); count.incrementAndGet(); }