From 960aa6f5096f0ea5f4e2b642e8f841bf863b5245 Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Thu, 8 Oct 2015 15:08:45 +0300 Subject: [PATCH] LatencyMetrics: Support totalLatencyHistogram and recentLatencyHistogram This adds the depricated total and recent estimated histogram. It uses the new RecentEstimatedHistogram for the recent value and the API based estimated histogram for the total latency. Signed-off-by: Amnon Heiman --- .../apache/cassandra/metrics/LatencyMetrics.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java b/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java index 596718e..6cce299 100644 --- a/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java +++ b/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java @@ -29,6 +29,8 @@ import java.util.concurrent.TimeUnit; import com.cloudius.urchin.metrics.APIMetrics; import com.cloudius.urchin.metrics.DefaultNameFactory; import com.cloudius.urchin.metrics.MetricNameFactory; +import com.cloudius.urchin.utils.EstimatedHistogram; +import com.cloudius.urchin.utils.RecentEstimatedHistogram; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.yammer.metrics.core.Counter; @@ -49,6 +51,12 @@ public class LatencyMetrics { protected final MetricNameFactory factory; protected final String namePrefix; + @Deprecated public EstimatedHistogramWrapper totalLatencyHistogram; + /* + * It should not be called directly, use the getRecentLatencyHistogram + */ + @Deprecated protected final RecentEstimatedHistogram recentLatencyHistogram = new RecentEstimatedHistogram(); + protected long lastLatency; protected long lastOpCount; @@ -106,6 +114,7 @@ public class LatencyMetrics { TimeUnit.MICROSECONDS, TimeUnit.SECONDS); totalLatency = APIMetrics.newCounter(url + paramName, factory.createMetricName(namePrefix + "TotalLatency")); + totalLatencyHistogram = new EstimatedHistogramWrapper(url + "/estimated_histogram" + paramName); } /** @@ -155,4 +164,8 @@ public class LatencyMetrics { lastOpCount = ops; } } + + public long[] getRecentLatencyHistogram() { + return recentLatencyHistogram.getBuckets(totalLatencyHistogram.getBuckets(false)); + } }