From 2cfe02acb8b325bdd0df061defdff9bbe4378685 Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Sun, 9 Aug 2015 14:27:24 +0300 Subject: [PATCH] LatencyMetrics: Support path parameter This change adds path parameter support, for the cases that the path parameter is the last on the path, for example in the ColumnFamily case Signed-off-by: Amnon Heiman --- .../cassandra/metrics/ColumnFamilyMetrics.java | 8 ++++---- .../apache/cassandra/metrics/LatencyMetrics.java | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java b/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java index c2193d9..8fa4f9e 100644 --- a/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java +++ b/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java @@ -252,13 +252,13 @@ public class ColumnFamilyMetrics { return c.getDoubleValue("/column_family/metrics/compression_ratio/"); } }); - readLatency = new LatencyMetrics("/column_family/metrics/read_latency/" - + cfName, factory, "Read"); + readLatency = new LatencyMetrics("/column_family/metrics/read_latency", + cfName, factory, "Read"); writeLatency = new LatencyMetrics( - "/column_family/metrics/write_latency/" + cfName, factory, + "/column_family/metrics/write_latency", cfName, factory, "Write"); rangeLatency = new LatencyMetrics( - "/column_family/metrics/range_latency/" + cfName, factory, + "/column_family/metrics/range_latency", cfName, factory, "Range"); pendingFlushes = createColumnFamilyCounter( "/column_family/metrics/pending_flushes", "PendingFlushes"); diff --git a/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java b/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java index 9fc4c24..27e7a8c 100644 --- a/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java +++ b/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java @@ -102,6 +102,18 @@ public class LatencyMetrics { factory.createMetricName(namePrefix + "TotalLatency")); } + public LatencyMetrics(String url, String paramName, + MetricNameFactory factory, String namePrefix) { + this.factory = factory; + this.namePrefix = namePrefix; + + latency = APIMetrics.newTimer(url + "/histogram/" + paramName, + factory.createMetricName(namePrefix + "Latency"), + TimeUnit.MICROSECONDS, TimeUnit.SECONDS); + totalLatency = APIMetrics.newCounter(url + "/" + paramName, + factory.createMetricName(namePrefix + "TotalLatency")); + } + /** * Create LatencyMetrics with given group, type, prefix to append to each * metric name, and scope. Any updates to this will also run on parent @@ -130,8 +142,8 @@ public class LatencyMetrics { } public void release() { - APIMetrics.defaultRegistry().removeMetric( - factory.createMetricName(namePrefix + "Latency")); + APIMetrics.defaultRegistry() + .removeMetric(factory.createMetricName(namePrefix + "Latency")); APIMetrics.defaultRegistry().removeMetric( factory.createMetricName(namePrefix + "TotalLatency")); }