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 <amnon@cloudius-systems.com>
This commit is contained in:
Amnon Heiman 2015-08-09 14:27:24 +03:00
parent 0ae282b548
commit 2cfe02acb8
2 changed files with 18 additions and 6 deletions

View File

@ -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");

View File

@ -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"));
}