Create and register the APISettableMetrics
This patch adds the ability to create and register the APISettableMettics. Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
parent
ac049129de
commit
1cb048effe
@ -288,6 +288,23 @@ public class APIMetrics {
|
||||
return DEFAULT_REGISTRY.newMeter(url, metricName, eventType, unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link com.yammer.metrics.core.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
|
||||
* @return a new {@link com.yammer.metrics.core.Meter}
|
||||
*/
|
||||
public static Meter newSettableMeter(MetricName metricName,
|
||||
String eventType, TimeUnit unit) {
|
||||
return DEFAULT_REGISTRY.newSettableMeter(metricName, eventType, unit);
|
||||
}
|
||||
/**
|
||||
* Creates a new {@link com.yammer.metrics.core.APITimer} and registers it
|
||||
* under the given class and name.
|
||||
|
@ -181,6 +181,28 @@ public class APIMetricsRegistry extends MetricsRegistry {
|
||||
eventType, unit, getClock()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link APISettableMeter} 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
|
||||
* @return a new {@link Meter}
|
||||
*/
|
||||
public Meter newSettableMeter(MetricName metricName, String eventType,
|
||||
TimeUnit unit) {
|
||||
final Metric existingMetric = getMetrics().get(metricName);
|
||||
if (existingMetric != null) {
|
||||
return (Meter) existingMetric;
|
||||
}
|
||||
return getOrAdd(metricName, new APISettableMeter(newMeterTickThreadPool(),
|
||||
eventType, unit, getClock()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Histogram} and registers it under the given class
|
||||
* and name.
|
||||
|
Loading…
Reference in New Issue
Block a user