@InterfaceAudience.Private public class MetricRegistryImpl extends Object implements MetricRegistry
MetricRegistry
.Modifier and Type | Field and Description |
---|---|
private MetricRegistryInfo |
info |
private ConcurrentMap<String,Metric> |
metrics |
Constructor and Description |
---|
MetricRegistryImpl(MetricRegistryInfo info) |
Modifier and Type | Method and Description |
---|---|
Counter |
counter(String name)
Get or construct a
Counter used to track a mutable number. |
protected Counter |
createCounter() |
protected Histogram |
createHistogram() |
protected Meter |
createMeter() |
protected Timer |
createTimer() |
Optional<Metric> |
get(String name)
Returns previously registered metric with the name if any.
|
MetricRegistryInfo |
getMetricRegistryInfo()
Return the MetricRegistryInfo object for this registry.
|
Map<String,Metric> |
getMetrics()
A map of metric names to metrics.
|
Histogram |
histogram(String name)
Get or construct a
Histogram used to measure a distribution of values. |
Meter |
meter(String name)
|
<T> Gauge<T> |
register(String name,
Gauge<T> gauge)
Register a
Gauge . |
Metric |
register(String name,
Metric metric)
Registers the
Metric with the given name if there does not exist one with the same
name. |
void |
registerAll(MetricSet metricSet)
Registers the
Metric s in the given MetricSet. |
boolean |
remove(String name)
Removes the metric with the given name.
|
Timer |
timer(String name)
Get or construct a
Timer used to measure durations and report rates. |
private final MetricRegistryInfo info
private final ConcurrentMap<String,Metric> metrics
public MetricRegistryImpl(MetricRegistryInfo info)
public Timer timer(String name)
MetricRegistry
Timer
used to measure durations and report rates.timer
in interface MetricRegistry
name
- the name of the timer.Timer
.protected Timer createTimer()
public Histogram histogram(String name)
MetricRegistry
Histogram
used to measure a distribution of values.histogram
in interface MetricRegistry
name
- The name of the Histogram.Histogram
.protected Histogram createHistogram()
public Meter meter(String name)
MetricRegistry
Meter
used to measure durations and report distributions (a
combination of a Timer
and a Histogram
.meter
in interface MetricRegistry
name
- The name of the Meter.Meter
.protected Meter createMeter()
public Counter counter(String name)
MetricRegistry
Counter
used to track a mutable number.counter
in interface MetricRegistry
name
- The name of the CounterCounter
.protected Counter createCounter()
public Optional<Metric> get(String name)
MetricRegistry
get
in interface MetricRegistry
name
- the name of the metricpublic Metric register(String name, Metric metric)
MetricRegistry
Metric
with the given name if there does not exist one with the same
name. Returns the newly registered or existing Metric.register
in interface MetricRegistry
name
- The name of the Metric.metric
- the metric to registerpublic <T> Gauge<T> register(String name, Gauge<T> gauge)
MetricRegistry
Gauge
. The Gauge will be invoked at a period defined by the implementation
of MetricRegistry
.register
in interface MetricRegistry
name
- The name of the Gauge.gauge
- A callback to compute the current value.public void registerAll(MetricSet metricSet)
MetricRegistry
Metric
s in the given MetricSet.registerAll
in interface MetricRegistry
metricSet
- set of metrics to register.public Map<String,Metric> getMetrics()
MetricSet
getMetrics
in interface MetricSet
public boolean remove(String name)
MetricRegistry
remove
in interface MetricRegistry
name
- the name of the metricpublic MetricRegistryInfo getMetricRegistryInfo()
MetricRegistry
getMetricRegistryInfo
in interface MetricRegistry
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.