use of org.graylog2.rest.models.metrics.responses.TimerMetricsResponse in project graylog2-server by Graylog2.
the class MetricUtils method buildTimerMap.
public static TimerRateMetricsResponse buildTimerMap(Timer t) {
final TimerRateMetricsResponse result = new TimerRateMetricsResponse();
final TimerMetricsResponse time = new TimerMetricsResponse();
final RateMetricsResponse rate = new RateMetricsResponse();
if (t == null) {
return result;
}
time.max = TimeUnit.MICROSECONDS.convert(t.getSnapshot().getMax(), TimeUnit.NANOSECONDS);
time.min = TimeUnit.MICROSECONDS.convert(t.getSnapshot().getMin(), TimeUnit.NANOSECONDS);
time.mean = TimeUnit.MICROSECONDS.convert((long) t.getSnapshot().getMean(), TimeUnit.NANOSECONDS);
time.percentile95th = TimeUnit.MICROSECONDS.convert((long) t.getSnapshot().get95thPercentile(), TimeUnit.NANOSECONDS);
time.percentile98th = TimeUnit.MICROSECONDS.convert((long) t.getSnapshot().get98thPercentile(), TimeUnit.NANOSECONDS);
time.percentile99th = TimeUnit.MICROSECONDS.convert((long) t.getSnapshot().get99thPercentile(), TimeUnit.NANOSECONDS);
time.stdDev = TimeUnit.MICROSECONDS.convert((long) t.getSnapshot().getStdDev(), TimeUnit.NANOSECONDS);
rate.oneMinute = t.getOneMinuteRate();
rate.fiveMinute = t.getFiveMinuteRate();
rate.fifteenMinute = t.getFifteenMinuteRate();
rate.total = t.getCount();
rate.mean = t.getMeanRate();
result.time = time;
result.rate = rate;
result.rateUnit = "events/second";
result.durationUnit = TimeUnit.MICROSECONDS.toString().toLowerCase(Locale.ENGLISH);
return result;
}
Aggregations