|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.yammer.metrics.core.MetricsRegistry
public class MetricsRegistry
A registry of metric instances.
| Constructor Summary | |
|---|---|
MetricsRegistry()
Creates a new MetricsRegistry. |
|
MetricsRegistry(Clock clock)
Creates a new MetricsRegistry with the given Clock instance. |
|
| Method Summary | ||
|---|---|---|
void |
addListener(MetricsRegistryListener listener)
Adds a MetricsRegistryListener to a collection of listeners that will be notified on
metric creation. |
|
Map<MetricName,Metric> |
allMetrics()
Returns an unmodifiable map of all metrics and their names. |
|
protected MetricName |
createName(Class<?> klass,
String name,
String scope)
Override to customize how MetricNames are created. |
|
protected
|
getOrAdd(MetricName name,
T metric)
Gets any existing metric with the given name or, if none exists, adds the given metric. |
|
SortedMap<String,SortedMap<MetricName,Metric>> |
groupedMetrics()
Returns a grouped and sorted map of all registered metrics. |
|
SortedMap<String,SortedMap<MetricName,Metric>> |
groupedMetrics(MetricPredicate predicate)
Returns a grouped and sorted map of all registered metrics which match then given MetricPredicate. |
|
Counter |
newCounter(Class<?> klass,
String name)
Creates a new Counter and registers it under the given class and name. |
|
Counter |
newCounter(Class<?> klass,
String name,
String scope)
Creates a new Counter and registers it under the given class and name. |
|
Counter |
newCounter(MetricName metricName)
Creates a new Counter and registers it under the given metric name. |
|
|
newGauge(Class<?> klass,
String name,
Gauge<T> metric)
Given a new Gauge, registers it under the given class and name. |
|
|
newGauge(Class<?> klass,
String name,
String scope,
Gauge<T> metric)
Given a new Gauge, registers it under the given class and name. |
|
|
newGauge(MetricName metricName,
Gauge<T> metric)
Given a new Gauge, registers it under the given metric name. |
|
Histogram |
newHistogram(Class<?> klass,
String name)
Creates a new non-biased Histogram and registers it under the given class and name. |
|
Histogram |
newHistogram(Class<?> klass,
String name,
boolean biased)
Creates a new Histogram and registers it under the given class and name. |
|
Histogram |
newHistogram(Class<?> klass,
String name,
String scope)
Creates a new non-biased Histogram and registers it under the given class, name, and
scope. |
|
Histogram |
newHistogram(Class<?> klass,
String name,
String scope,
boolean biased)
Creates a new Histogram and registers it under the given class, name, and scope. |
|
Histogram |
newHistogram(MetricName metricName,
boolean biased)
Creates a new Histogram and registers it under the given metric name. |
|
Meter |
newMeter(Class<?> klass,
String name,
String scope,
String eventType,
TimeUnit unit)
Creates a new Meter and registers it under the given class, name, and scope. |
|
Meter |
newMeter(Class<?> klass,
String name,
String eventType,
TimeUnit unit)
Creates a new Meter and registers it under the given class and name. |
|
Meter |
newMeter(MetricName metricName,
String eventType,
TimeUnit unit)
Creates a new Meter and registers it under the given metric name. |
|
protected ConcurrentMap<MetricName,Metric> |
newMetricsMap()
Returns a new ConcurrentMap implementation. |
|
ScheduledExecutorService |
newScheduledThreadPool(int poolSize,
String name)
Creates a new scheduled thread pool of a given size with the given name, or returns an existing thread pool if one was already created with the same name. |
|
Timer |
newTimer(Class<?> klass,
String name)
Creates a new Timer and registers it under the given class and name, measuring
elapsed time in milliseconds and invocations per second. |
|
Timer |
newTimer(Class<?> klass,
String name,
String scope)
Creates a new Timer and registers it under the given class, name, and scope,
measuring elapsed time in milliseconds and invocations per second. |
|
Timer |
newTimer(Class<?> klass,
String name,
String scope,
TimeUnit durationUnit,
TimeUnit rateUnit)
Creates a new Timer and registers it under the given class, name, and scope. |
|
Timer |
newTimer(Class<?> klass,
String name,
TimeUnit durationUnit,
TimeUnit rateUnit)
Creates a new Timer and registers it under the given class and name. |
|
Timer |
newTimer(MetricName metricName,
TimeUnit durationUnit,
TimeUnit rateUnit)
Creates a new Timer and registers it under the given metric name. |
|
void |
removeListener(MetricsRegistryListener listener)
Removes a MetricsRegistryListener from this registry's collection of listeners. |
|
void |
removeMetric(Class<?> klass,
String name)
Removes the metric for the given class with the given name. |
|
void |
removeMetric(Class<?> klass,
String name,
String scope)
Removes the metric for the given class with the given name and scope. |
|
void |
removeMetric(MetricName name)
Removes the metric with the given name. |
|
void |
shutdown()
Shut down this registry's thread pools. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MetricsRegistry()
MetricsRegistry.
public MetricsRegistry(Clock clock)
MetricsRegistry with the given Clock instance.
clock - a Clock instance| Method Detail |
|---|
public <T> Gauge<T> newGauge(Class<?> klass,
String name,
Gauge<T> metric)
Gauge, registers it under the given class and name.
T - the type of the value returned by the metricklass - the class which owns the metricname - the name of the metricmetric - the metric
metric
public <T> Gauge<T> newGauge(Class<?> klass,
String name,
String scope,
Gauge<T> metric)
Gauge, registers it under the given class and name.
T - the type of the value returned by the metricklass - the class which owns the metricname - the name of the metricscope - the scope of the metricmetric - the metric
metric
public <T> Gauge<T> newGauge(MetricName metricName,
Gauge<T> metric)
Gauge, registers it under the given metric name.
T - the type of the value returned by the metricmetricName - the name of the metricmetric - the metric
metric
public Counter newCounter(Class<?> klass,
String name)
Counter and registers it under the given class and name.
klass - the class which owns the metricname - the name of the metric
Counter
public Counter newCounter(Class<?> klass,
String name,
String scope)
Counter and registers it under the given class and name.
klass - the class which owns the metricname - the name of the metricscope - the scope of the metric
Counterpublic Counter newCounter(MetricName metricName)
Counter and registers it under the given metric name.
metricName - the name of the metric
Counter
public Histogram newHistogram(Class<?> klass,
String name,
boolean biased)
Histogram and registers it under the given class and name.
klass - the class which owns the metricname - the name of the metricbiased - whether or not the histogram should be biased
Histogram
public Histogram newHistogram(Class<?> klass,
String name,
String scope,
boolean biased)
Histogram and registers it under the given class, name, and scope.
klass - the class which owns the metricname - the name of the metricscope - the scope of the metricbiased - whether or not the histogram should be biased
Histogram
public Histogram newHistogram(Class<?> klass,
String name)
Histogram and registers it under the given class and name.
klass - the class which owns the metricname - the name of the metric
Histogram
public Histogram newHistogram(Class<?> klass,
String name,
String scope)
Histogram and registers it under the given class, name, and
scope.
klass - the class which owns the metricname - the name of the metricscope - the scope of the metric
Histogram
public Histogram newHistogram(MetricName metricName,
boolean biased)
Histogram and registers it under the given metric name.
metricName - the name of the metricbiased - whether or not the histogram should be biased
Histogram
public Meter newMeter(Class<?> klass,
String name,
String eventType,
TimeUnit unit)
Meter and registers it under the given class and name.
klass - the class which owns the metricname - the name of the metriceventType - the plural name of the type of events the meter is measuring (e.g., "requests")unit - the rate unit of the new meter
Meter
public Meter newMeter(Class<?> klass,
String name,
String scope,
String eventType,
TimeUnit unit)
Meter and registers it under the given class, name, and scope.
klass - the class which owns the metricname - the name of the metricscope - the scope of the metriceventType - the plural name of the type of events the meter is measuring (e.g., "requests")unit - the rate unit of the new meter
Meter
public Meter newMeter(MetricName metricName,
String eventType,
TimeUnit unit)
Meter and registers it under the given metric name.
metricName - the name of the metriceventType - the plural name of the type of events the meter is measuring (e.g., "requests")unit - the rate unit of the new meter
Meter
public Timer newTimer(Class<?> klass,
String name)
Timer and registers it under the given class and name, measuring
elapsed time in milliseconds and invocations per second.
klass - the class which owns the metricname - the name of the metric
Timer
public Timer newTimer(Class<?> klass,
String name,
TimeUnit durationUnit,
TimeUnit rateUnit)
Timer and registers it under the given class and name.
klass - the class which owns the metricname - the name of the metricdurationUnit - the duration scale unit of the new timerrateUnit - the rate scale unit of the new timer
Timer
public Timer newTimer(Class<?> klass,
String name,
String scope)
Timer and registers it under the given class, name, and scope,
measuring elapsed time in milliseconds and invocations per second.
klass - the class which owns the metricname - the name of the metricscope - the scope of the metric
Timer
public Timer newTimer(Class<?> klass,
String name,
String scope,
TimeUnit durationUnit,
TimeUnit rateUnit)
Timer and registers it under the given class, name, and scope.
klass - the class which owns the metricname - the name of the metricscope - the scope of the metricdurationUnit - the duration scale unit of the new timerrateUnit - the rate scale unit of the new timer
Timer
public Timer newTimer(MetricName metricName,
TimeUnit durationUnit,
TimeUnit rateUnit)
Timer and registers it under the given metric name.
metricName - the name of the metricdurationUnit - the duration scale unit of the new timerrateUnit - the rate scale unit of the new timer
Timerpublic Map<MetricName,Metric> allMetrics()
public SortedMap<String,SortedMap<MetricName,Metric>> groupedMetrics()
public SortedMap<String,SortedMap<MetricName,Metric>> groupedMetrics(MetricPredicate predicate)
MetricPredicate.
predicate - a predicate which metrics have to match to be in the results
predicate, sorted by namepublic void shutdown()
public ScheduledExecutorService newScheduledThreadPool(int poolSize,
String name)
poolSize - the number of threads to createname - the name of the pool
ScheduledExecutorService
public void removeMetric(Class<?> klass,
String name)
klass - the klass the metric is associated withname - the name of the metric
public void removeMetric(Class<?> klass,
String name,
String scope)
klass - the klass the metric is associated withname - the name of the metricscope - the scope of the metricpublic void removeMetric(MetricName name)
name - the name of the metricpublic void addListener(MetricsRegistryListener listener)
MetricsRegistryListener to a collection of listeners that will be notified on
metric creation. Listeners will be notified in the order in which they are added.
N.B.: The listener will be notified of all existing metrics when it first registers.
listener - the listener that will be notifiedpublic void removeListener(MetricsRegistryListener listener)
MetricsRegistryListener from this registry's collection of listeners.
listener - the listener that will be removed
protected MetricName createName(Class<?> klass,
String name,
String scope)
MetricNames are created.
klass - the class which owns the metricname - the name of the metricscope - the metric's scope
protected ConcurrentMap<MetricName,Metric> newMetricsMap()
ConcurrentMap implementation. Subclass this to do weird things with
your own MetricsRegistry implementation.
ConcurrentMap
protected final <T extends Metric> T getOrAdd(MetricName name,
T metric)
T - the type of the metricname - the metric's namemetric - the new metric
metric
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||