diff --git a/src/main/java/com/cloudius/urchin/api/APIClient.java b/src/main/java/com/cloudius/urchin/api/APIClient.java index 9e22846..cddeebd 100644 --- a/src/main/java/com/cloudius/urchin/api/APIClient.java +++ b/src/main/java/com/cloudius/urchin/api/APIClient.java @@ -31,6 +31,7 @@ import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.yammer.metrics.core.HistogramValues; import javax.ws.rs.core.MediaType; @@ -485,4 +486,37 @@ public class APIClient { // TODO Auto-generated method stub return null; } + + public JsonObject getJsonObj(String string, + MultivaluedMap queryParams) { + if (string.equals("")) { + return null; + } + JsonReader reader = getReader(string, queryParams); + JsonObject res = reader.readObject(); + reader.close(); + return res; + } + + public HistogramValues getHistogramValue(String url, + MultivaluedMap queryParams) { + HistogramValues res = new HistogramValues(); + JsonObject obj = getJsonObj(url, queryParams); + res.count = obj.getJsonNumber("count").longValue(); + res.max = obj.getJsonNumber("max").longValue(); + res.min = obj.getJsonNumber("min").longValue(); + res.sum = obj.getJsonNumber("sum").longValue(); + res.variance = obj.getJsonNumber("variance").doubleValue(); + res.svariance = obj.getJsonNumber("svariance").doubleValue(); + JsonArray arr = obj.getJsonArray("sample"); + res.sample = new long[arr.size()]; + for (int i = 0; i < arr.size(); i++) { + res.sample[i] = arr.getJsonNumber(i).longValue(); + } + return res; + } + + public HistogramValues getHistogramValue(String url) { + return getHistogramValue(url, null); + } } diff --git a/src/main/java/com/cloudius/urchin/metrics/APIMetrics.java b/src/main/java/com/cloudius/urchin/metrics/APIMetrics.java index bcdfdcb..6abd51c 100644 --- a/src/main/java/com/cloudius/urchin/metrics/APIMetrics.java +++ b/src/main/java/com/cloudius/urchin/metrics/APIMetrics.java @@ -14,6 +14,7 @@ import com.yammer.metrics.core.Gauge; import com.yammer.metrics.core.Histogram; import com.yammer.metrics.core.Meter; import com.yammer.metrics.core.MetricName; +import com.yammer.metrics.core.APITimer; import com.yammer.metrics.core.Timer; import com.yammer.metrics.reporting.JmxReporter; @@ -288,7 +289,7 @@ public class APIMetrics { } /** - * Creates a new {@link com.yammer.metrics.core.Timer} and registers it + * Creates a new {@link com.yammer.metrics.core.APITimer} and registers it * under the given class and name. * * @param klass @@ -299,15 +300,15 @@ public class APIMetrics { * the duration scale unit of the new timer * @param rateUnit * the rate scale unit of the new timer - * @return a new {@link com.yammer.metrics.core.Timer} + * @return a new {@link com.yammer.metrics.core.APITimer} */ - public static Timer newTimer(Class klass, String name, + public static Timer newTimer(String url, Class klass, String name, TimeUnit durationUnit, TimeUnit rateUnit) { - return DEFAULT_REGISTRY.newTimer(klass, name, durationUnit, rateUnit); + return DEFAULT_REGISTRY.newTimer(url, klass, name, durationUnit, rateUnit); } /** - * Creates a new {@link com.yammer.metrics.core.Timer} and registers it + * Creates a new {@link com.yammer.metrics.core.APITimer} and registers it * under the given class and name, measuring elapsed time in milliseconds * and invocations per second. * @@ -315,14 +316,14 @@ public class APIMetrics { * the class which owns the metric * @param name * the name of the metric - * @return a new {@link com.yammer.metrics.core.Timer} + * @return a new {@link com.yammer.metrics.core.APITimer} */ - public static Timer newTimer(Class klass, String name) { - return DEFAULT_REGISTRY.newTimer(klass, name); + public static Timer newTimer(String url, Class klass, String name) { + return DEFAULT_REGISTRY.newTimer(url, klass, name); } /** - * Creates a new {@link com.yammer.metrics.core.Timer} and registers it + * Creates a new {@link com.yammer.metrics.core.APITimer} and registers it * under the given class, name, and scope. * * @param klass @@ -335,16 +336,16 @@ public class APIMetrics { * the duration scale unit of the new timer * @param rateUnit * the rate scale unit of the new timer - * @return a new {@link com.yammer.metrics.core.Timer} + * @return a new {@link com.yammer.metrics.core.APITimer} */ - public static Timer newTimer(Class klass, String name, String scope, + public static Timer newTimer(String url, Class klass, String name, String scope, TimeUnit durationUnit, TimeUnit rateUnit) { - return DEFAULT_REGISTRY.newTimer(klass, name, scope, durationUnit, + return DEFAULT_REGISTRY.newTimer(url, klass, name, scope, durationUnit, rateUnit); } /** - * Creates a new {@link com.yammer.metrics.core.Timer} and registers it + * Creates a new {@link com.yammer.metrics.core.APITimer} and registers it * under the given class, name, and scope, measuring elapsed time in * milliseconds and invocations per second. * @@ -354,14 +355,14 @@ public class APIMetrics { * the name of the metric * @param scope * the scope of the metric - * @return a new {@link com.yammer.metrics.core.Timer} + * @return a new {@link com.yammer.metrics.core.APITimer} */ - public static Timer newTimer(Class klass, String name, String scope) { - return DEFAULT_REGISTRY.newTimer(klass, name, scope); + public static Timer newTimer(String url, Class klass, String name, String scope) { + return DEFAULT_REGISTRY.newTimer(url, klass, name, scope); } /** - * Creates a new {@link com.yammer.metrics.core.Timer} and registers it + * Creates a new {@link com.yammer.metrics.core.APITimer} and registers it * under the given metric name. * * @param metricName @@ -370,11 +371,11 @@ public class APIMetrics { * the duration scale unit of the new timer * @param rateUnit * the rate scale unit of the new timer - * @return a new {@link com.yammer.metrics.core.Timer} + * @return a new {@link com.yammer.metrics.core.APITimer} */ - public static Timer newTimer(MetricName metricName, TimeUnit durationUnit, + public static Timer newTimer(String url, MetricName metricName, TimeUnit durationUnit, TimeUnit rateUnit) { - return DEFAULT_REGISTRY.newTimer(metricName, durationUnit, rateUnit); + return DEFAULT_REGISTRY.newTimer(url, metricName, durationUnit, rateUnit); } /** diff --git a/src/main/java/com/yammer/metrics/core/APIHistogram.java b/src/main/java/com/yammer/metrics/core/APIHistogram.java index 8ccdbb0..777abc1 100644 --- a/src/main/java/com/yammer/metrics/core/APIHistogram.java +++ b/src/main/java/com/yammer/metrics/core/APIHistogram.java @@ -6,24 +6,93 @@ package com.yammer.metrics.core; * Modified by Cloudius Systems */ +import java.lang.reflect.Field; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; + import com.cloudius.urchin.api.APIClient; import com.yammer.metrics.stats.Sample; import com.yammer.metrics.stats.Snapshot; public class APIHistogram extends Histogram { + Field countField; + Field minField; + Field maxField; + Field sumField; + Field varianceField; + Field sampleField; + long last_update = 0; static final long UPDATE_INTERVAL = 50; + long updateInterval; String url; private APIClient c = new APIClient(); - public APIHistogram(String _url, Sample sample) { - super(sample); - url = _url; + private void setFields() { + try { + minField = Histogram.class.getDeclaredField("min"); + minField.setAccessible(true); + maxField = Histogram.class.getDeclaredField("max"); + maxField.setAccessible(true); + sumField = Histogram.class.getDeclaredField("sum"); + sumField.setAccessible(true); + varianceField = Histogram.class.getDeclaredField("variance"); + varianceField.setAccessible(true); + sampleField = Histogram.class.getDeclaredField("sample"); + sampleField.setAccessible(true); + countField = Histogram.class.getDeclaredField("count"); + countField.setAccessible(true); + } catch (NoSuchFieldException | SecurityException e) { + e.printStackTrace(); + } } - public APIHistogram(String _url, SampleType type) { + public AtomicLong getMin() throws IllegalArgumentException, + IllegalAccessException { + return (AtomicLong) minField.get(this); + } + + public AtomicLong getMax() throws IllegalArgumentException, + IllegalAccessException { + return (AtomicLong) maxField.get(this); + } + + public AtomicLong getSum() throws IllegalArgumentException, + IllegalAccessException { + return (AtomicLong) sumField.get(this); + } + + public AtomicLong getCount() throws IllegalArgumentException, + IllegalAccessException { + return (AtomicLong) countField.get(this); + } + + @SuppressWarnings("unchecked") + public AtomicReference getVariance() + throws IllegalArgumentException, IllegalAccessException { + return (AtomicReference) varianceField.get(this); + } + + public Sample getSample() throws IllegalArgumentException, + IllegalAccessException { + return (Sample) sampleField.get(this); + } + + public APIHistogram(String url, Sample sample) { + super(sample); + setFields(); + this.url = url; + } + + public APIHistogram(String url, SampleType type, long updateInterval) { super(type); - url = _url; + setFields(); + this.url = url; + this.updateInterval = updateInterval; + } + + public APIHistogram(String url, SampleType type) { + this(url, type, UPDATE_INTERVAL); } public void update() { @@ -33,9 +102,21 @@ public class APIHistogram extends Histogram { } last_update = now; clear(); - long[] vals = c.getLongArrValue(url); - for (long v : vals) { - update(v); + HistogramValues vals = c.getHistogramValue(url); + try { + for (long v : vals.sample) { + getSample().update(v); + } + getCount().set(vals.count); + getMax().set(vals.max); + getMin().set(vals.min); + getSum().set(vals.sum); + double[] newValue = new double[2]; + newValue[0] = vals.variance; + newValue[1] = vals.svariance; + getVariance().getAndSet(newValue); + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); } } diff --git a/src/main/java/com/yammer/metrics/core/APIMetricsRegistry.java b/src/main/java/com/yammer/metrics/core/APIMetricsRegistry.java index b9242b0..c02955e 100644 --- a/src/main/java/com/yammer/metrics/core/APIMetricsRegistry.java +++ b/src/main/java/com/yammer/metrics/core/APIMetricsRegistry.java @@ -23,18 +23,19 @@ import com.yammer.metrics.core.Histogram.SampleType; */ public class APIMetricsRegistry extends MetricsRegistry { - Field field_metrics; - Field field_clock; - Field field_thread_pool; - + Field fieldMetrics; + Field fieldClock; + Field fieldThreadPool; + public APIMetricsRegistry() { try { - field_metrics = MetricsRegistry.class.getDeclaredField("metrics"); - field_metrics.setAccessible(true); - field_clock = MetricsRegistry.class.getDeclaredField("clock"); - field_clock.setAccessible(true); - field_thread_pool = MetricsRegistry.class.getDeclaredField("threadPools"); - field_thread_pool.setAccessible(true); + fieldMetrics = MetricsRegistry.class.getDeclaredField("metrics"); + fieldMetrics.setAccessible(true); + fieldClock = MetricsRegistry.class.getDeclaredField("clock"); + fieldClock.setAccessible(true); + fieldThreadPool = MetricsRegistry.class + .getDeclaredField("threadPools"); + fieldThreadPool.setAccessible(true); } catch (NoSuchFieldException | SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -43,192 +44,319 @@ public class APIMetricsRegistry extends MetricsRegistry { public ThreadPools getThreadPools() { try { - return (ThreadPools)field_thread_pool.get(this); + return (ThreadPools) fieldThreadPool.get(this); } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); + e.printStackTrace(); } return null; } - + public Clock getClock() { try { - return (Clock)field_clock.get(this); + return (Clock) fieldClock.get(this); } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); + e.printStackTrace(); } return null; } - + @SuppressWarnings("unchecked") - public ConcurrentMap get_metrics() { + public ConcurrentMap getMetrics() { try { - return (ConcurrentMap)field_metrics.get(this); + return (ConcurrentMap) fieldMetrics.get(this); } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); + e.printStackTrace(); } return null; } + /** - * Creates a new {@link Counter} and registers it under the given class and name. + * Creates a new {@link Counter} and registers it under the given class and + * name. * - * @param klass the class which owns the metric - * @param name the name of the metric + * @param klass + * the class which owns the metric + * @param name + * the name of the metric * @return a new {@link Counter} */ - public Counter newCounter(String url, Class klass, - String name) { + public Counter newCounter(String url, Class klass, String name) { return newCounter(url, klass, name, null); } /** - * Creates a new {@link Counter} and registers it under the given class and name. + * Creates a new {@link Counter} and registers it under the given class and + * name. * - * @param klass the class which owns the metric - * @param name the name of the metric - * @param scope the scope of the metric + * @param klass + * the class which owns the metric + * @param name + * the name of the metric + * @param scope + * the scope of the metric * @return a new {@link Counter} */ - public Counter newCounter(String url, Class klass, - String name, - String scope) { + public Counter newCounter(String url, Class klass, String name, + String scope) { return newCounter(url, createName(klass, name, scope)); } + /** - * Creates a new {@link Counter} and registers it under the given metric name. + * Creates a new {@link Counter} and registers it under the given metric + * name. * - * @param metricName the name of the metric + * @param metricName + * the name of the metric * @return a new {@link Counter} */ public Counter newCounter(String url, MetricName metricName) { return getOrAdd(metricName, new APICounter(url)); } - + /** - * Creates a new {@link Meter} and registers it under the given class and name. + * Creates a new {@link Meter} and registers it under the given class and + * name. * - * @param klass the class which owns the metric - * @param name the name of the metric - * @param eventType the plural name of the type of events the meter is measuring (e.g., {@code - * "requests"}) - * @param unit the rate unit of the new meter + * @param klass + * the class which owns the metric + * @param name + * the name of the metric + * @param eventType + * the plural name of the type of events the meter is measuring + * (e.g., {@code "requests"}) + * @param unit + * the rate unit of the new meter * @return a new {@link Meter} */ - public Meter newMeter(String url, Class klass, - String name, - String eventType, - TimeUnit unit) { + public Meter newMeter(String url, Class klass, String name, + String eventType, TimeUnit unit) { return newMeter(url, klass, name, null, eventType, unit); } /** - * Creates a new {@link Meter} and registers it under the given class, name, and scope. + * Creates a new {@link Meter} and registers it under the given class, name, + * and scope. * - * @param klass the class which owns the metric - * @param name the name of the metric - * @param scope the scope of the metric - * @param eventType the plural name of the type of events the meter is measuring (e.g., {@code - * "requests"}) - * @param unit the rate unit of the new meter + * @param klass + * the class which owns the metric + * @param name + * the name of the metric + * @param scope + * the scope of the metric + * @param eventType + * the plural name of the type of events the meter is measuring + * (e.g., {@code "requests"}) + * @param unit + * the rate unit of the new meter * @return a new {@link Meter} */ - public Meter newMeter(String url, - Class klass, - String name, - String scope, - String eventType, - TimeUnit unit) { + public Meter newMeter(String url, Class klass, String name, + String scope, String eventType, TimeUnit unit) { return newMeter(url, createName(klass, name, scope), eventType, unit); } private ScheduledExecutorService newMeterTickThreadPool() { return getThreadPools().newScheduledThreadPool(2, "meter-tick"); } + /** * Creates a new {@link Meter} and registers it under the given metric name. * - * @param metricName the name of the metric - * @param eventType the plural name of the type of events the meter is measuring (e.g., {@code - * "requests"}) - * @param unit the rate unit of the new meter + * @param metricName + * the name of the metric + * @param eventType + * the plural name of the type of events the meter is measuring + * (e.g., {@code "requests"}) + * @param unit + * the rate unit of the new meter * @return a new {@link Meter} */ - public Meter newMeter(String url, MetricName metricName, - String eventType, - TimeUnit unit) { - final Metric existingMetric = get_metrics().get(metricName); + public Meter newMeter(String url, MetricName metricName, String eventType, + TimeUnit unit) { + final Metric existingMetric = getMetrics().get(metricName); if (existingMetric != null) { return (Meter) existingMetric; } - return getOrAdd(metricName, new APIMeter(url, newMeterTickThreadPool(), eventType, unit, getClock())); + return getOrAdd(metricName, new APIMeter(url, newMeterTickThreadPool(), + eventType, unit, getClock())); } - + /** - * Creates a new {@link Histogram} and registers it under the given class and name. + * Creates a new {@link Histogram} and registers it under the given class + * and name. * - * @param klass the class which owns the metric - * @param name the name of the metric - * @param biased whether or not the histogram should be biased + * @param klass + * the class which owns the metric + * @param name + * the name of the metric + * @param biased + * whether or not the histogram should be biased * @return a new {@link Histogram} */ - public Histogram newHistogram(String url, Class klass, - String name, - boolean biased) { + public Histogram newHistogram(String url, Class klass, String name, + boolean biased) { return newHistogram(url, klass, name, null, biased); } /** - * Creates a new {@link Histogram} and registers it under the given class, name, and scope. + * Creates a new {@link Histogram} and registers it under the given class, + * name, and scope. * - * @param klass the class which owns the metric - * @param name the name of the metric - * @param scope the scope of the metric - * @param biased whether or not the histogram should be biased + * @param klass + * the class which owns the metric + * @param name + * the name of the metric + * @param scope + * the scope of the metric + * @param biased + * whether or not the histogram should be biased * @return a new {@link Histogram} */ - public Histogram newHistogram(String url, Class klass, - String name, - String scope, - boolean biased) { + public Histogram newHistogram(String url, Class klass, String name, + String scope, boolean biased) { return newHistogram(url, createName(klass, name, scope), biased); } /** - * Creates a new non-biased {@link Histogram} and registers it under the given class and name. + * Creates a new non-biased {@link Histogram} and registers it under the + * given class and name. * - * @param klass the class which owns the metric - * @param name the name of the metric + * @param klass + * the class which owns the metric + * @param name + * the name of the metric * @return a new {@link Histogram} */ - public Histogram newHistogram(String url, Class klass, - String name) { + public Histogram newHistogram(String url, Class klass, String name) { return newHistogram(url, klass, name, false); } /** - * Creates a new non-biased {@link Histogram} and registers it under the given class, name, and - * scope. + * Creates a new non-biased {@link Histogram} and registers it under the + * given class, name, and scope. * - * @param klass the class which owns the metric - * @param name the name of the metric - * @param scope the scope of the metric + * @param klass + * the class which owns the metric + * @param name + * the name of the metric + * @param scope + * the scope of the metric * @return a new {@link Histogram} */ - public Histogram newHistogram(String url, Class klass, - String name, - String scope) { + public Histogram newHistogram(String url, Class klass, String name, + String scope) { return newHistogram(url, klass, name, scope, false); } /** - * Creates a new {@link Histogram} and registers it under the given metric name. + * Creates a new {@link Histogram} and registers it under the given metric + * name. * - * @param metricName the name of the metric - * @param biased whether or not the histogram should be biased + * @param metricName + * the name of the metric + * @param biased + * whether or not the histogram should be biased * @return a new {@link Histogram} */ public Histogram newHistogram(String url, MetricName metricName, - boolean biased) { - return getOrAdd(metricName, - new APIHistogram(url, biased ? SampleType.BIASED : SampleType.UNIFORM)); + boolean biased) { + return getOrAdd(metricName, new APIHistogram(url, + biased ? SampleType.BIASED : SampleType.UNIFORM)); } + + /** + * Creates a new {@link Timer} and registers it under the given class and + * name, measuring elapsed time in milliseconds and invocations per second. + * + * @param klass + * the class which owns the metric + * @param name + * the name of the metric + * @return a new {@link Timer} + */ + public Timer newTimer(String url, Class klass, String name) { + return newTimer(url, klass, name, null, TimeUnit.MILLISECONDS, + TimeUnit.SECONDS); + } + + /** + * Creates a new {@link Timer} and registers it under the given class and + * name. + * + * @param klass + * the class which owns the metric + * @param name + * the name of the metric + * @param durationUnit + * the duration scale unit of the new timer + * @param rateUnit + * the rate scale unit of the new timer + * @return a new {@link Timer} + */ + public Timer newTimer(String url, Class klass, String name, + TimeUnit durationUnit, TimeUnit rateUnit) { + return newTimer(url, klass, name, null, durationUnit, rateUnit); + } + + /** + * Creates a new {@link Timer} and registers it under the given class, name, + * and scope, measuring elapsed time in milliseconds and invocations per + * second. + * + * @param klass + * the class which owns the metric + * @param name + * the name of the metric + * @param scope + * the scope of the metric + * @return a new {@link Timer} + */ + public Timer newTimer(String url, Class klass, String name, String scope) { + return newTimer(url, klass, name, scope, TimeUnit.MILLISECONDS, + TimeUnit.SECONDS); + } + + /** + * Creates a new {@link Timer} and registers it under the given class, name, + * and scope. + * + * @param klass + * the class which owns the metric + * @param name + * the name of the metric + * @param scope + * the scope of the metric + * @param durationUnit + * the duration scale unit of the new timer + * @param rateUnit + * the rate scale unit of the new timer + * @return a new {@link Timer} + */ + public Timer newTimer(String url, Class klass, String name, + String scope, TimeUnit durationUnit, TimeUnit rateUnit) { + return newTimer(url, createName(klass, name, scope), durationUnit, + rateUnit); + } + + /** + * Creates a new {@link Timer} and registers it under the given metric name. + * + * @param metricName + * the name of the metric + * @param durationUnit + * the duration scale unit of the new timer + * @param rateUnit + * the rate scale unit of the new timer + * @return a new {@link Timer} + */ + public Timer newTimer(String url, MetricName metricName, + TimeUnit durationUnit, TimeUnit rateUnit) { + final Metric existingMetric = getMetrics().get(metricName); + if (existingMetric != null) { + return (Timer) existingMetric; + } + return getOrAdd(metricName, new APITimer(url, newMeterTickThreadPool(), + durationUnit, rateUnit, getClock())); + } + } diff --git a/src/main/java/com/yammer/metrics/core/APITimer.java b/src/main/java/com/yammer/metrics/core/APITimer.java new file mode 100644 index 0000000..b750f56 --- /dev/null +++ b/src/main/java/com/yammer/metrics/core/APITimer.java @@ -0,0 +1,44 @@ +/* + * Copyright 2015 Cloudius Systems + * + */ +package com.yammer.metrics.core; + +import java.lang.reflect.Field; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import com.yammer.metrics.core.Histogram.SampleType; + +/** + * A timer metric which aggregates timing durations and provides duration + * statistics, plus throughput statistics via {@link Meter}. + */ +public class APITimer extends Timer { + + public APITimer(String url, ScheduledExecutorService tickThread, + TimeUnit durationUnit, TimeUnit rateUnit) { + super(tickThread, durationUnit, rateUnit); + setHistogram(url); + } + + public APITimer(String url, ScheduledExecutorService tickThread, + TimeUnit durationUnit, TimeUnit rateUnit, Clock clock) { + super(tickThread, durationUnit, rateUnit, clock); + setHistogram(url); + } + + private void setHistogram(String url) { + Field histogram; + try { + histogram = Timer.class.getDeclaredField("histogram"); + histogram.setAccessible(true); + histogram.set(this, new APIHistogram(url, SampleType.BIASED)); + } catch (NoSuchFieldException | SecurityException + | IllegalArgumentException | IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/main/java/com/yammer/metrics/core/HistogramValues.java b/src/main/java/com/yammer/metrics/core/HistogramValues.java new file mode 100644 index 0000000..6da13fb --- /dev/null +++ b/src/main/java/com/yammer/metrics/core/HistogramValues.java @@ -0,0 +1,11 @@ +package com.yammer.metrics.core; + +public class HistogramValues { + public long count; + public long min; + public long max; + public long sum; + public double variance; + public double svariance; + public long sample[]; +} diff --git a/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java b/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java index cb0fc7f..5f3cd91 100644 --- a/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java +++ b/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java @@ -325,13 +325,13 @@ public class ColumnFamilyMetrics { colUpdateTimeDeltaHistogram = createColumnFamilyHistogram( "/column_family/metrics/col_update_time_delta_histogram", "ColUpdateTimeDeltaHistogram"); - coordinatorReadLatency = Metrics.newTimer( + coordinatorReadLatency = APIMetrics.newTimer("/column_family/metrics/coordinator/read/" + cfName, factory.createMetricName("CoordinatorReadLatency"), TimeUnit.MICROSECONDS, TimeUnit.SECONDS); - coordinatorScanLatency = Metrics.newTimer( + coordinatorScanLatency = APIMetrics.newTimer("/column_family/metrics/coordinator/scan/" + cfName, factory.createMetricName("CoordinatorScanLatency"), TimeUnit.MICROSECONDS, TimeUnit.SECONDS); - waitingOnFreeMemtableSpace = Metrics.newTimer( + waitingOnFreeMemtableSpace = APIMetrics.newTimer("/column_family/metrics/waiting_on_free_memtable/" + cfName, factory.createMetricName("WaitingOnFreeMemtableSpace"), TimeUnit.MICROSECONDS, TimeUnit.SECONDS); diff --git a/src/main/java/org/apache/cassandra/metrics/CommitLogMetrics.java b/src/main/java/org/apache/cassandra/metrics/CommitLogMetrics.java index b1677fa..aacf2f8 100644 --- a/src/main/java/org/apache/cassandra/metrics/CommitLogMetrics.java +++ b/src/main/java/org/apache/cassandra/metrics/CommitLogMetrics.java @@ -77,10 +77,10 @@ public class CommitLogMetrics { return c.getLongValue("/commitlog/metrics/total_commit_log_size"); } }); - waitingOnSegmentAllocation = APIMetrics.newTimer( + waitingOnSegmentAllocation = APIMetrics.newTimer("/commit_log/metrics/waiting_on_segment_allocation", factory.createMetricName("WaitingOnSegmentAllocation"), TimeUnit.MICROSECONDS, TimeUnit.SECONDS); - waitingOnCommit = APIMetrics.newTimer( + waitingOnCommit = APIMetrics.newTimer("/commit_log/metrics/waiting_on_commit", factory.createMetricName("WaitingOnCommit"), TimeUnit.MICROSECONDS, TimeUnit.SECONDS); } diff --git a/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java b/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java index 8a99d3e..9fc4c24 100644 --- a/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java +++ b/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java @@ -95,7 +95,7 @@ public class LatencyMetrics { this.factory = factory; this.namePrefix = namePrefix; - latency = APIMetrics.newTimer( + latency = APIMetrics.newTimer(url + "/histogram", factory.createMetricName(namePrefix + "Latency"), TimeUnit.MICROSECONDS, TimeUnit.SECONDS); totalLatency = APIMetrics.newCounter(url,