MetricsRegistry: Solving empty histograms in nodetool
This patch fixes two issues with the histogram implementation:
* Need to all update before trying to read values from the histogram.
* The histogram values return from the API in microseconds and not nano.
See Scylladb/scylla#2155
Signed-off-by: Amnon Heiman <amnon@scylladb.com>
Message-Id: <20170315130725.22261-1-amnon@scylladb.com>
(cherry picked from commit 0c541d73e7
)
This commit is contained in:
parent
4586c90544
commit
4b367372a6
@ -196,11 +196,11 @@ public class MetricsRegistry {
|
||||
|
||||
private static final TimeUnit RATE_UNIT = TimeUnit.SECONDS;
|
||||
private static final TimeUnit DURATION_UNIT = TimeUnit.MICROSECONDS;
|
||||
private static final TimeUnit API_DURATION_UNIT = TimeUnit.NANOSECONDS;
|
||||
private static final TimeUnit API_DURATION_UNIT = TimeUnit.MICROSECONDS;
|
||||
private static final double DURATION_FACTOR = 1.0 / API_DURATION_UNIT.convert(1, DURATION_UNIT);
|
||||
|
||||
private static double toDuration(double nanos) {
|
||||
return nanos * DURATION_FACTOR;
|
||||
private static double toDuration(double micro) {
|
||||
return micro * DURATION_FACTOR;
|
||||
}
|
||||
|
||||
private static String unitString(TimeUnit u) {
|
||||
@ -650,61 +650,73 @@ public class MetricsRegistry {
|
||||
|
||||
@Override
|
||||
public double getMin() {
|
||||
update();
|
||||
return toDuration(histogram.getMin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMax() {
|
||||
update();
|
||||
return toDuration(histogram.getMax());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMean() {
|
||||
update();
|
||||
return toDuration(histogram.getMean());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getStdDev() {
|
||||
update();
|
||||
return toDuration(histogram.getStdDev());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double get50thPercentile() {
|
||||
update();
|
||||
return toDuration(histogram.getValue(.5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double get75thPercentile() {
|
||||
update();
|
||||
return toDuration(histogram.getValue(.75));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double get95thPercentile() {
|
||||
update();
|
||||
return toDuration(histogram.getValue(.95));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double get98thPercentile() {
|
||||
update();
|
||||
return toDuration(histogram.getValue(.98));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double get99thPercentile() {
|
||||
update();
|
||||
return toDuration(histogram.getValue(.99));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double get999thPercentile() {
|
||||
update();
|
||||
return toDuration(histogram.getValue(.999));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] values() {
|
||||
update();
|
||||
return histogram.getValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDurationUnit() {
|
||||
update();
|
||||
return DURATION_UNIT.toString().toLowerCase(Locale.US);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user