| Modifier and Type | Class and Description |
|---|---|
static interface |
MetricRegistry.MetricBuilder<T extends Metric>
A quick and easy way of capturing the notion of default metrics.
|
| Modifier | Constructor and Description |
|---|---|
|
MetricRegistry()
Creates a new
MetricRegistry. |
protected |
MetricRegistry(ConcurrentMap<MetricName,Metric> metricsMap)
Creates a
MetricRegistry with a custom ConcurrentMap implementation for use
inside the registry. |
| 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. |
Counter |
counter(MetricName name)
|
Counter |
counter(String name) |
SortedMap<MetricName,Counter> |
getCounters()
Returns a map of all the counters in the registry and their names.
|
SortedMap<MetricName,Counter> |
getCounters(MetricFilter filter)
Returns a map of all the counters in the registry and their names which match the given
filter.
|
SortedMap<MetricName,Gauge> |
getGauges()
Returns a map of all the gauges in the registry and their names.
|
SortedMap<MetricName,Gauge> |
getGauges(MetricFilter filter)
Returns a map of all the gauges in the registry and their names which match the given filter.
|
SortedMap<MetricName,Histogram> |
getHistograms()
Returns a map of all the histograms in the registry and their names.
|
SortedMap<MetricName,Histogram> |
getHistograms(MetricFilter filter)
Returns a map of all the histograms in the registry and their names which match the given
filter.
|
SortedMap<MetricName,Meter> |
getMeters()
Returns a map of all the meters in the registry and their names.
|
SortedMap<MetricName,Meter> |
getMeters(MetricFilter filter)
Returns a map of all the meters in the registry and their names which match the given filter.
|
Map<MetricName,Metric> |
getMetrics()
A map of metric names to metrics.
|
SortedSet<MetricName> |
getNames()
Returns a set of the names of all the metrics in the registry.
|
<T extends Metric> |
getOrAdd(MetricName name,
MetricRegistry.MetricBuilder<T> builder) |
SortedMap<MetricName,Timer> |
getTimers()
Returns a map of all the timers in the registry and their names.
|
SortedMap<MetricName,Timer> |
getTimers(MetricFilter filter)
Returns a map of all the timers in the registry and their names which match the given filter.
|
Histogram |
histogram(MetricName name)
|
Histogram |
histogram(String name) |
Meter |
meter(MetricName name)
|
Meter |
meter(String name) |
static MetricName |
name(Class<?> klass,
String... names) |
static MetricName |
name(String name,
String... names)
Shorthand method for backwards compatibility in creating metric names.
|
<T extends Metric> |
register(MetricName name,
T metric)
Given a
Metric, registers it under the given name. |
<T extends Metric> |
register(String name,
T metric) |
void |
registerAll(MetricSet metrics)
Given a metric set, registers them.
|
boolean |
remove(MetricName name)
Removes the metric with the given name.
|
void |
removeAll()
Removes all the metrics in registry.
|
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(MetricName name)
|
Timer |
timer(String name) |
public MetricRegistry()
MetricRegistry.protected MetricRegistry(ConcurrentMap<MetricName,Metric> metricsMap)
MetricRegistry with a custom ConcurrentMap implementation for use
inside the registry. Call as the super-constructor to create a MetricRegistry with
space- or time-bounded metric lifecycles, for example.metricsMap - metricsMappublic static MetricName name(Class<?> klass, String... names)
klass - klassnames - namesname(String, String...)public static MetricName name(String name, String... names)
MetricName.build(String...) for its
heavy lifting.name - The first element of the namenames - The remaining elements of the nameMetricName.build(String...)public <T extends Metric> T register(String name, T metric) throws IllegalArgumentException
T - type of metricsname - namemetric - metricmetricIllegalArgumentExceptionregister(MetricName, Metric)public <T extends Metric> T register(MetricName name, T metric) throws IllegalArgumentException
Metric, registers it under the given name.T - the type of the metricname - the name of the metricmetric - the metricmetricIllegalArgumentException - 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)
name - namecounter(MetricName)public Counter counter(MetricName name)
Counter registered under this name; or create and register
a new Counter if none is registered.name - the name of the metricCounterpublic Histogram histogram(String name)
name - namehistogram(MetricName)public Histogram histogram(MetricName name)
Histogram registered under this name; or create and register
a new Histogram if none is registered.name - the name of the metricHistogrampublic Meter meter(String name)
name - namemeter(MetricName)public Meter meter(MetricName name)
Meter registered under this name; or create and register
a new Meter if none is registered.name - the name of the metricMeterpublic Timer timer(String name)
name - nametimer(MetricName)public Timer timer(MetricName name)
Timer registered under this name; or create and register
a new Timer if none is registered.name - the name of the metricTimerpublic boolean remove(MetricName name)
name - the name of the metricpublic void removeAll()
public 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<MetricName> getNames()
public SortedMap<MetricName,Gauge> getGauges()
public SortedMap<MetricName,Gauge> getGauges(MetricFilter filter)
filter - the metric filter to matchpublic SortedMap<MetricName,Counter> getCounters()
public SortedMap<MetricName,Counter> getCounters(MetricFilter filter)
filter - the metric filter to matchpublic SortedMap<MetricName,Histogram> getHistograms()
public SortedMap<MetricName,Histogram> getHistograms(MetricFilter filter)
filter - the metric filter to matchpublic SortedMap<MetricName,Meter> getMeters()
public SortedMap<MetricName,Meter> getMeters(MetricFilter filter)
filter - the metric filter to matchpublic SortedMap<MetricName,Timer> getTimers()
public SortedMap<MetricName,Timer> getTimers(MetricFilter filter)
filter - the metric filter to matchpublic <T extends Metric> T getOrAdd(MetricName name, MetricRegistry.MetricBuilder<T> builder)
public Map<MetricName,Metric> getMetrics()
MetricSetgetMetrics in interface MetricSetCopyright © 2021. All rights reserved.