Package io.dropwizard.metrics5
Class NoopMetricRegistry
- java.lang.Object
-
- io.dropwizard.metrics5.MetricRegistry
-
- io.dropwizard.metrics5.NoopMetricRegistry
-
public final class NoopMetricRegistry extends MetricRegistry
A registry of metric instances which never creates or registers any metrics and returns no-op implementations of any metric type.- Since:
- 4.1.17
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.dropwizard.metrics5.MetricRegistry
MetricRegistry.MetricSupplier<T extends Metric>
-
-
Constructor Summary
Constructors Constructor Description NoopMetricRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(MetricRegistryListener listener)
Adds aMetricRegistryListener
to a collection of listeners that will be notified on metric creation.protected ConcurrentMap<MetricName,Metric>
buildMap()
Creates a newConcurrentMap
implementation for use inside the registry.Counter
counter(MetricName name)
<T extends Counter>
Tcounter(MetricName name, MetricRegistry.MetricSupplier<T> supplier)
Counter
counter(String name)
<T extends Gauge>
Tgauge(MetricName name)
Return theGauge
registered under this name; or create and register a newSettableGauge
if none is registered.<T extends Gauge>
Tgauge(MetricName name, MetricRegistry.MetricSupplier<T> supplier)
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.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(MetricName name, MetricRegistry.MetricSupplier<Histogram> supplier)
Histogram
histogram(String name)
Meter
meter(MetricName name)
Meter
meter(MetricName name, MetricRegistry.MetricSupplier<Meter> supplier)
Meter
meter(String name)
<T extends Metric>
Tregister(MetricName name, T metric)
Given aMetric
, registers it under the given name.<T extends Metric>
Tregister(String name, T metric)
void
registerAll(MetricName prefix, MetricSet metrics)
void
registerAll(MetricSet metrics)
Given a metric set, registers them.boolean
remove(MetricName name)
Removes the metric with the given name.void
removeListener(MetricRegistryListener listener)
Removes aMetricRegistryListener
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(MetricName name, MetricRegistry.MetricSupplier<Timer> supplier)
Timer
timer(String name)
-
Methods inherited from class io.dropwizard.metrics5.MetricRegistry
name, name
-
-
-
-
Method Detail
-
buildMap
protected ConcurrentMap<MetricName,Metric> buildMap()
Creates a newConcurrentMap
implementation for use inside the registry. Override this to create aMetricRegistry
with space- or time-bounded metric lifecycles, for example.- Overrides:
buildMap
in classMetricRegistry
- Returns:
-
register
public <T extends Metric> T register(String name, T metric) throws IllegalArgumentException
- Overrides:
register
in classMetricRegistry
- Throws:
IllegalArgumentException
-
registerAll
public void registerAll(MetricSet metrics) throws IllegalArgumentException
Given a metric set, registers them.- Overrides:
registerAll
in classMetricRegistry
- Parameters:
metrics
- a set of metrics- Throws:
IllegalArgumentException
- if any of the names are already registered
-
counter
public Counter counter(String name)
- Overrides:
counter
in classMetricRegistry
-
counter
public Counter counter(MetricName name)
Return theCounter
registered under this name; or create and register a newCounter
if none is registered.- Overrides:
counter
in classMetricRegistry
- Parameters:
name
- the name of the metric- Returns:
- a new or pre-existing
Counter
-
counter
public <T extends Counter> T counter(MetricName name, MetricRegistry.MetricSupplier<T> supplier)
Return theCounter
registered under this name; or create and register a newCounter
using the provided MetricSupplier if none is registered.- Overrides:
counter
in classMetricRegistry
- Parameters:
name
- the name of the metricsupplier
- a MetricSupplier that can be used to manufacture a counter.- Returns:
- a new or pre-existing
Counter
-
histogram
public Histogram histogram(String name)
- Overrides:
histogram
in classMetricRegistry
-
histogram
public Histogram histogram(MetricName name)
Return theHistogram
registered under this name; or create and register a newHistogram
if none is registered.- Overrides:
histogram
in classMetricRegistry
- Parameters:
name
- the name of the metric- Returns:
- a new or pre-existing
Histogram
-
histogram
public Histogram histogram(MetricName name, MetricRegistry.MetricSupplier<Histogram> supplier)
Return theHistogram
registered under this name; or create and register a newHistogram
using the provided MetricSupplier if none is registered.- Overrides:
histogram
in classMetricRegistry
- Parameters:
name
- the name of the metricsupplier
- a MetricSupplier that can be used to manufacture a histogram- Returns:
- a new or pre-existing
Histogram
-
meter
public Meter meter(String name)
- Overrides:
meter
in classMetricRegistry
-
meter
public Meter meter(MetricName name)
Return theMeter
registered under this name; or create and register a newMeter
if none is registered.- Overrides:
meter
in classMetricRegistry
- Parameters:
name
- the name of the metric- Returns:
- a new or pre-existing
Meter
-
meter
public Meter meter(MetricName name, MetricRegistry.MetricSupplier<Meter> supplier)
Return theMeter
registered under this name; or create and register a newMeter
using the provided MetricSupplier if none is registered.- Overrides:
meter
in classMetricRegistry
- Parameters:
name
- the name of the metricsupplier
- a MetricSupplier that can be used to manufacture a Meter- Returns:
- a new or pre-existing
Meter
-
timer
public Timer timer(String name)
- Overrides:
timer
in classMetricRegistry
-
timer
public Timer timer(MetricName name)
Return theTimer
registered under this name; or create and register a newTimer
if none is registered.- Overrides:
timer
in classMetricRegistry
- Parameters:
name
- the name of the metric- Returns:
- a new or pre-existing
Timer
-
gauge
public <T extends Gauge> T gauge(MetricName name)
Return theGauge
registered under this name; or create and register a newSettableGauge
if none is registered.- Overrides:
gauge
in classMetricRegistry
- Parameters:
name
- the name of the metric- Returns:
- a pre-existing
Gauge
or a newSettableGauge
- Since:
- 4.2
-
timer
public Timer timer(MetricName name, MetricRegistry.MetricSupplier<Timer> supplier)
Return theTimer
registered under this name; or create and register a newTimer
using the provided MetricSupplier if none is registered.- Overrides:
timer
in classMetricRegistry
- Parameters:
name
- the name of the metricsupplier
- a MetricSupplier that can be used to manufacture a Timer- Returns:
- a new or pre-existing
Timer
-
gauge
public <T extends Gauge> T gauge(MetricName name, MetricRegistry.MetricSupplier<T> supplier)
Return theGauge
registered under this name; or create and register a newGauge
using the provided MetricSupplier if none is registered.- Overrides:
gauge
in classMetricRegistry
- Parameters:
name
- the name of the metricsupplier
- a MetricSupplier that can be used to manufacture a Gauge- Returns:
- a new or pre-existing
Gauge
-
remove
public boolean remove(MetricName name)
Removes the metric with the given name.- Overrides:
remove
in classMetricRegistry
- Parameters:
name
- the name of the metric- Returns:
- whether or not the metric was removed
-
removeMatching
public void removeMatching(MetricFilter filter)
Removes all metrics which match the given filter.- Overrides:
removeMatching
in classMetricRegistry
- Parameters:
filter
- a filter
-
addListener
public void addListener(MetricRegistryListener listener)
Adds aMetricRegistryListener
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.
- Overrides:
addListener
in classMetricRegistry
- Parameters:
listener
- the listener that will be notified
-
removeListener
public void removeListener(MetricRegistryListener listener)
Removes aMetricRegistryListener
from this registry's collection of listeners.- Overrides:
removeListener
in classMetricRegistry
- Parameters:
listener
- the listener that will be removed
-
getNames
public SortedSet<MetricName> getNames()
Returns a set of the names of all the metrics in the registry.- Overrides:
getNames
in classMetricRegistry
- Returns:
- the names of all the metrics
-
getGauges
public SortedMap<MetricName,Gauge<?>> getGauges()
Returns a map of all the gauges in the registry and their names.- Overrides:
getGauges
in classMetricRegistry
- Returns:
- all the gauges in the registry
-
getGauges
public SortedMap<MetricName,Gauge<?>> getGauges(MetricFilter filter)
Returns a map of all the gauges in the registry and their names which match the given filter.- Overrides:
getGauges
in classMetricRegistry
- Parameters:
filter
- the metric filter to match- Returns:
- all the gauges in the registry
-
getCounters
public SortedMap<MetricName,Counter> getCounters()
Returns a map of all the counters in the registry and their names.- Overrides:
getCounters
in classMetricRegistry
- Returns:
- all the counters in the registry
-
getCounters
public SortedMap<MetricName,Counter> getCounters(MetricFilter filter)
Returns a map of all the counters in the registry and their names which match the given filter.- Overrides:
getCounters
in classMetricRegistry
- Parameters:
filter
- the metric filter to match- Returns:
- all the counters in the registry
-
getHistograms
public SortedMap<MetricName,Histogram> getHistograms()
Returns a map of all the histograms in the registry and their names.- Overrides:
getHistograms
in classMetricRegistry
- Returns:
- all the histograms in the registry
-
getHistograms
public SortedMap<MetricName,Histogram> getHistograms(MetricFilter filter)
Returns a map of all the histograms in the registry and their names which match the given filter.- Overrides:
getHistograms
in classMetricRegistry
- Parameters:
filter
- the metric filter to match- Returns:
- all the histograms in the registry
-
getMeters
public SortedMap<MetricName,Meter> getMeters()
Returns a map of all the meters in the registry and their names.- Overrides:
getMeters
in classMetricRegistry
- Returns:
- all the meters in the registry
-
getMeters
public SortedMap<MetricName,Meter> getMeters(MetricFilter filter)
Returns a map of all the meters in the registry and their names which match the given filter.- Overrides:
getMeters
in classMetricRegistry
- Parameters:
filter
- the metric filter to match- Returns:
- all the meters in the registry
-
getTimers
public SortedMap<MetricName,Timer> getTimers()
Returns a map of all the timers in the registry and their names.- Overrides:
getTimers
in classMetricRegistry
- Returns:
- all the timers in the registry
-
getTimers
public SortedMap<MetricName,Timer> getTimers(MetricFilter filter)
Returns a map of all the timers in the registry and their names which match the given filter.- Overrides:
getTimers
in classMetricRegistry
- Parameters:
filter
- the metric filter to match- Returns:
- all the timers in the registry
-
registerAll
public void registerAll(MetricName prefix, MetricSet metrics) throws IllegalArgumentException
- Overrides:
registerAll
in classMetricRegistry
- Throws:
IllegalArgumentException
-
register
public <T extends Metric> T register(MetricName name, T metric) throws IllegalArgumentException
Given aMetric
, registers it under the given name.- Overrides:
register
in classMetricRegistry
- Type Parameters:
T
- the type of the metric- Parameters:
name
- the name of the metricmetric
- the metric- Returns:
metric
- Throws:
IllegalArgumentException
- if the name is already registered or metric variable is null
-
getMetrics
public Map<MetricName,Metric> getMetrics()
A map of metric names to metrics.- Specified by:
getMetrics
in interfaceMetricSet
- Overrides:
getMetrics
in classMetricRegistry
- Returns:
- the metrics
-
-