Constructor and Description |
---|
MetricRegistry()
Creates a new
MetricRegistry . |
Modifier and Type | Method and Description |
---|---|
void |
addListener(MetricRegistryListener listener)
Adds a
MetricRegistryListener to a collection of listeners that will be notified on
metric creation. |
protected ConcurrentMap<String,Metric> |
buildMap()
Creates a new
ConcurrentMap implementation for use inside the registry. |
Counter |
counter(String name)
Creates a new
Counter and registers it under the given name. |
SortedMap<String,Counter> |
getCounters()
Returns a map of all the counters in the registry and their names.
|
SortedMap<String,Counter> |
getCounters(MetricFilter filter)
Returns a map of all the counters in the registry and their names which match the given
filter.
|
SortedMap<String,Gauge> |
getGauges()
Returns a map of all the gauges in the registry and their names.
|
SortedMap<String,Gauge> |
getGauges(MetricFilter filter)
Returns a map of all the gauges in the registry and their names which match the given filter.
|
SortedMap<String,Histogram> |
getHistograms()
Returns a map of all the histograms in the registry and their names.
|
SortedMap<String,Histogram> |
getHistograms(MetricFilter filter)
Returns a map of all the histograms in the registry and their names which match the given
filter.
|
SortedMap<String,Meter> |
getMeters()
Returns a map of all the meters in the registry and their names.
|
SortedMap<String,Meter> |
getMeters(MetricFilter filter)
Returns a map of all the meters in the registry and their names which match the given filter.
|
Map<String,Metric> |
getMetrics()
A map of metric names to metrics.
|
SortedSet<String> |
getNames()
Returns a set of the names of all the metrics in the registry.
|
SortedMap<String,Timer> |
getTimers()
Returns a map of all the timers in the registry and their names.
|
SortedMap<String,Timer> |
getTimers(MetricFilter filter)
Returns a map of all the timers in the registry and their names which match the given filter.
|
Histogram |
histogram(String name)
Creates a new
Histogram and registers it under the given name. |
Meter |
meter(String name)
Creates a new
Meter and registers it under the given name. |
static String |
name(Class<?> klass,
String... names)
Concatenates a class name and elements to form a dotted name, eliding any null values or
empty strings.
|
static String |
name(String name,
String... names)
Concatenates elements to form a dotted name, eliding any null values or empty strings.
|
<T extends Metric> |
register(String name,
T metric)
Given a
Metric , registers it under the given name. |
void |
registerAll(MetricSet metrics)
Given a metric set, registers them.
|
boolean |
remove(String name)
Removes the metric with the given name.
|
void |
removeListener(MetricRegistryListener listener)
Removes a
MetricRegistryListener from this registry's collection of listeners. |
void |
removeMatching(MetricFilter filter)
Removes all metrics which match the given filter.
|
Timer |
timer(String name)
Creates a new
Timer and registers it under the given name. |
public MetricRegistry()
MetricRegistry
.public static String name(String name, String... names)
name
- the first element of the namenames
- the remaining elements of the namename
and names
concatenated by periodspublic static String name(Class<?> klass, String... names)
klass
- the first element of the namenames
- the remaining elements of the nameklass
and names
concatenated by periodsprotected ConcurrentMap<String,Metric> buildMap()
ConcurrentMap
implementation for use inside the registry. Override this
to create a MetricRegistry
with space- or time-bounded metric lifecycles, for
example.ConcurrentMap
public <T extends Metric> T register(String name, T metric) throws IllegalArgumentException
Metric
, registers it under the given name.T
- the type of the metricname
- the name of the metricmetric
- the metricmetric
IllegalArgumentException
- if the name is already registeredpublic void registerAll(MetricSet metrics) throws IllegalArgumentException
metrics
- a set of metricsIllegalArgumentException
- if any of the names are already registeredpublic Counter counter(String name)
Counter
and registers it under the given name.name
- the name of the metricCounter
public Histogram histogram(String name)
Histogram
and registers it under the given name.name
- the name of the metricHistogram
public Meter meter(String name)
Meter
and registers it under the given name.name
- the name of the metricMeter
public Timer timer(String name)
Timer
and registers it under the given name.name
- the name of the metricTimer
public boolean remove(String name)
name
- the name of the metricpublic void removeMatching(MetricFilter filter)
filter
- a filterpublic void addListener(MetricRegistryListener listener)
MetricRegistryListener
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(MetricRegistryListener listener)
MetricRegistryListener
from this registry's collection of listeners.listener
- the listener that will be removedpublic SortedSet<String> getNames()
public SortedMap<String,Gauge> getGauges()
public SortedMap<String,Gauge> getGauges(MetricFilter filter)
filter
- the metric filter to matchpublic SortedMap<String,Counter> getCounters()
public SortedMap<String,Counter> getCounters(MetricFilter filter)
filter
- the metric filter to matchpublic SortedMap<String,Histogram> getHistograms()
public SortedMap<String,Histogram> getHistograms(MetricFilter filter)
filter
- the metric filter to matchpublic SortedMap<String,Meter> getMeters()
public SortedMap<String,Meter> getMeters(MetricFilter filter)
filter
- the metric filter to matchpublic SortedMap<String,Timer> getTimers()
public SortedMap<String,Timer> getTimers(MetricFilter filter)
filter
- the metric filter to matchCopyright © 2014. All Rights Reserved.