Class MetricRegistry
- java.lang.Object
-
- org.eclipse.microprofile.metrics.MetricRegistry
-
public abstract class MetricRegistry extends java.lang.Object
The registry that stores metrics and their metadata. The MetricRegistry provides methods to register, create and retrieve metrics and their respective metadata.- See Also:
MetricFilter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MetricRegistry.Type
An enumeration representing the scopes of the MetricRegistry
-
Constructor Summary
Constructors Constructor Description MetricRegistry()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ConcurrentGauge
concurrentGauge(java.lang.String name)
Return theConcurrentGauge
registered under theMetricID
with this name; or create and register a newConcurrentGauge
if none is registered.abstract ConcurrentGauge
concurrentGauge(java.lang.String name, Tag... tags)
Return theConcurrentGauge
registered under theMetricID
with this name and with the providedTag
s; or create and register a newConcurrentGauge
if none is registered.abstract ConcurrentGauge
concurrentGauge(Metadata metadata)
Return theConcurrentGauge
registered under theMetricID
with theMetadata
's name; or create and register a newConcurrentGauge
if none is registered.abstract ConcurrentGauge
concurrentGauge(Metadata metadata, Tag... tags)
Return theConcurrentGauge
registered under theMetricID
with theMetadata
's name and with the providedTag
s; or create and register a newConcurrentGauge
if none is registered.abstract Counter
counter(java.lang.String name)
abstract Counter
counter(java.lang.String name, Tag... tags)
abstract Counter
counter(Metadata metadata)
abstract Counter
counter(Metadata metadata, Tag... tags)
abstract java.util.SortedMap<MetricID,ConcurrentGauge>
getConcurrentGauges()
Returns a map of all the concurrent gauges in the registry and theirMetricID
s.abstract java.util.SortedMap<MetricID,ConcurrentGauge>
getConcurrentGauges(MetricFilter filter)
Returns a map of all the concurrent gauges in the registry and theirMetricID
s which match the given filter.abstract java.util.SortedMap<MetricID,Counter>
getCounters()
Returns a map of all the counters in the registry and theirMetricID
s.abstract java.util.SortedMap<MetricID,Counter>
getCounters(MetricFilter filter)
Returns a map of all the counters in the registry and theirMetricID
s which match the given filter.abstract java.util.SortedMap<MetricID,Gauge>
getGauges()
Returns a map of all the gauges in the registry and theirMetricID
s.abstract java.util.SortedMap<MetricID,Gauge>
getGauges(MetricFilter filter)
Returns a map of all the gauges in the registry and theirMetricID
s which match the given filter.abstract java.util.SortedMap<MetricID,Histogram>
getHistograms()
Returns a map of all the histograms in the registry and theirMetricID
s.abstract java.util.SortedMap<MetricID,Histogram>
getHistograms(MetricFilter filter)
Returns a map of all the histograms in the registry and theirMetricID
s which match the given filter.abstract java.util.Map<java.lang.String,Metadata>
getMetadata()
Returns a map of all the metadata in the registry and their names.abstract java.util.SortedMap<MetricID,Meter>
getMeters()
Returns a map of all the meters in the registry and theirMetricID
s.abstract java.util.SortedMap<MetricID,Meter>
getMeters(MetricFilter filter)
Returns a map of all the meters in the registry and theirMetricID
s which match the given filter.abstract java.util.SortedSet<MetricID>
getMetricIDs()
Returns a set of theMetricID
s of all the metrics in the registry.abstract java.util.Map<MetricID,Metric>
getMetrics()
Returns a map of all the metrics in the registry and theirMetricID
s.abstract java.util.SortedSet<java.lang.String>
getNames()
Returns a set of the names of all the metrics in the registry.abstract java.util.SortedMap<MetricID,Timer>
getTimers()
Returns a map of all the timers in the registry and theirMetricID
s.abstract java.util.SortedMap<MetricID,Timer>
getTimers(MetricFilter filter)
Returns a map of all the timers in the registry and theirMetricID
s which match the given filter.abstract Histogram
histogram(java.lang.String name)
abstract Histogram
histogram(java.lang.String name, Tag... tags)
abstract Histogram
histogram(Metadata metadata)
abstract Histogram
histogram(Metadata metadata, Tag... tags)
abstract Meter
meter(java.lang.String name)
abstract Meter
meter(java.lang.String name, Tag... tags)
abstract Meter
meter(Metadata metadata)
abstract Meter
meter(Metadata metadata, Tag... tags)
static java.lang.String
name(java.lang.Class<?> klass, java.lang.String... names)
Concatenates a class name and elements to form a dotted name, eliding any null values or empty strings.static java.lang.String
name(java.lang.String name, java.lang.String... names)
Concatenates elements to form a dotted name, eliding any null values or empty strings.abstract <T extends Metric>
Tregister(java.lang.String name, T metric)
abstract <T extends Metric>
Tregister(Metadata metadata, T metric)
abstract <T extends Metric>
Tregister(Metadata metadata, T metric, Tag... tags)
abstract boolean
remove(java.lang.String name)
Removes all metrics with the given name.abstract boolean
remove(MetricID metricID)
Removes the metric with the given MetricIDabstract void
removeMatching(MetricFilter filter)
Removes all metrics which match the given filter.abstract Timer
timer(java.lang.String name)
abstract Timer
timer(java.lang.String name, Tag... tags)
abstract Timer
timer(Metadata metadata)
abstract Timer
timer(Metadata metadata, Tag... tags)
-
-
-
Method Detail
-
name
public static java.lang.String name(java.lang.String name, java.lang.String... names)
Concatenates elements to form a dotted name, eliding any null values or empty strings.- Parameters:
name
- the first element of the namenames
- the remaining elements of the name- Returns:
name
andnames
concatenated by periods
-
name
public static java.lang.String name(java.lang.Class<?> klass, java.lang.String... names)
Concatenates a class name and elements to form a dotted name, eliding any null values or empty strings.- Parameters:
klass
- the first element of the namenames
- the remaining elements of the name- Returns:
klass
andnames
concatenated by periods
-
register
public abstract <T extends Metric> T register(java.lang.String name, T metric) throws java.lang.IllegalArgumentException
Given aMetric
, registers it under aMetricID
with the given name and with no tags. AMetadata
object will be registered with the name and type. However, if aMetadata
object is already registered with this metric name and is not equal to the createdMetadata
object then an exception will be thrown.- Type Parameters:
T
- the type of the metric- Parameters:
name
- the name of the metricmetric
- the metric- Returns:
metric
- Throws:
java.lang.IllegalArgumentException
- if the name is already registered or if Metadata with different values has already been registered with the name
-
register
public abstract <T extends Metric> T register(Metadata metadata, T metric) throws java.lang.IllegalArgumentException
Given aMetric
andMetadata
, registers the metric with aMetricID
with the name provided by theMetadata
and with no tags.Note: If a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Type Parameters:
T
- the type of the metric- Parameters:
metadata
- the metadatametric
- the metric- Returns:
metric
- Throws:
java.lang.IllegalArgumentException
- if the name is already registered or if Metadata with different values has already been registered with the name- Since:
- 1.1
-
register
public abstract <T extends Metric> T register(Metadata metadata, T metric, Tag... tags) throws java.lang.IllegalArgumentException
Given aMetric
andMetadata
, registers both under aMetricID
with the name provided by theMetadata
and with the providedTag
s.Note: If a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Type Parameters:
T
- the type of the metric- Parameters:
metadata
- the metadatametric
- the metrictags
- the tags of the metric- Returns:
metric
- Throws:
java.lang.IllegalArgumentException
- if the name is already registered or if Metadata with different values has already been registered with the name- Since:
- 2.0
-
counter
public abstract Counter counter(java.lang.String name)
Return theCounter
registered under theMetricID
with this name and with no tags; or create and register a newCounter
if none is registered. If aCounter
was created, aMetadata
object will be registered with the name and type. If aMetadata
object is already registered with this metric name then thatMetadata
will be used.- Parameters:
name
- the name of the metric- Returns:
- a new or pre-existing
Counter
-
counter
public abstract Counter counter(java.lang.String name, Tag... tags)
Return theCounter
registered under theMetricID
with this name and with the providedTag
s; or create and register a newCounter
if none is registered. If aCounter
was created, aMetadata
object will be registered with the name and type. If aMetadata
object is already registered with this metric name then thatMetadata
will be used.- Parameters:
name
- the name of the metrictags
- the tags of the metric- Returns:
- a new or pre-existing
Counter
- Since:
- 2.0
-
counter
public abstract Counter counter(Metadata metadata)
Return theCounter
registered under theMetricID
with theMetadata
's name and with no tags; or create and register a newCounter
if none is registered. If aCounter
was created, the providedMetadata
object will be registered.Note: During retrieval or creation, if a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Parameters:
metadata
- the name of the metric- Returns:
- a new or pre-existing
Counter
-
counter
public abstract Counter counter(Metadata metadata, Tag... tags)
Return theCounter
registered under theMetricID
with theMetadata
's name and with the providedTag
s; or create and register a newCounter
if none is registered. If aCounter
was created, the providedMetadata
object will be registered.Note: During retrieval or creation, if a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Parameters:
metadata
- the name of the metrictags
- the tags of the metric- Returns:
- a new or pre-existing
Counter
- Since:
- 2.0
-
concurrentGauge
public abstract ConcurrentGauge concurrentGauge(java.lang.String name)
Return theConcurrentGauge
registered under theMetricID
with this name; or create and register a newConcurrentGauge
if none is registered. If aConcurrentGauge
was created, aMetadata
object will be registered with the name and type.- Parameters:
name
- the name of the metric- Returns:
- a new or pre-existing
ConcurrentGauge
-
concurrentGauge
public abstract ConcurrentGauge concurrentGauge(java.lang.String name, Tag... tags)
Return theConcurrentGauge
registered under theMetricID
with this name and with the providedTag
s; or create and register a newConcurrentGauge
if none is registered. If aConcurrentGauge
was created, aMetadata
object will be registered with the name and type.- Parameters:
name
- the name of the metrictags
- the tags of the metric- Returns:
- a new or pre-existing
ConcurrentGauge
-
concurrentGauge
public abstract ConcurrentGauge concurrentGauge(Metadata metadata)
Return theConcurrentGauge
registered under theMetricID
with theMetadata
's name; or create and register a newConcurrentGauge
if none is registered. If aConcurrentGauge
was created, the providedMetadata
object will be registered.Note: During retrieval or creation, if a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Parameters:
metadata
- the name of the metric- Returns:
- a new or pre-existing
ConcurrentGauge
-
concurrentGauge
public abstract ConcurrentGauge concurrentGauge(Metadata metadata, Tag... tags)
Return theConcurrentGauge
registered under theMetricID
with theMetadata
's name and with the providedTag
s; or create and register a newConcurrentGauge
if none is registered. If aConcurrentGauge
was created, the providedMetadata
object will be registered.Note: During retrieval or creation, if a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Parameters:
metadata
- the name of the metrictags
- the tags of the metric- Returns:
- a new or pre-existing
ConcurrentGauge
-
histogram
public abstract Histogram histogram(java.lang.String name)
Return theHistogram
registered under theMetricID
with this name and with no tags; or create and register a newHistogram
if none is registered. If aHistogram
was created, aMetadata
object will be registered with the name and type. If aMetadata
object is already registered with this metric name then thatMetadata
will be used.- Parameters:
name
- the name of the metric- Returns:
- a new or pre-existing
Histogram
-
histogram
public abstract Histogram histogram(java.lang.String name, Tag... tags)
Return theHistogram
registered under theMetricID
with this name and with the providedTag
s; or create and register a newHistogram
if none is registered. If aHistogram
was created, aMetadata
object will be registered with the name and type. If aMetadata
object is already registered with this metric name then thatMetadata
will be used.- Parameters:
name
- the name of the metrictags
- the tags of the metric- Returns:
- a new or pre-existing
Histogram
- Since:
- 2.0
-
histogram
public abstract Histogram histogram(Metadata metadata)
Return theHistogram
registered under theMetricID
with theMetadata
's name and with no tags; or create and register a newHistogram
if none is registered. If aHistogram
was created, the providedMetadata
object will be registered.Note: During retrieval or creation, if a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Parameters:
metadata
- the name of the metric- Returns:
- a new or pre-existing
Histogram
-
histogram
public abstract Histogram histogram(Metadata metadata, Tag... tags)
Return theHistogram
registered under theMetricID
with theMetadata
's name and with the providedTag
s; or create and register a newHistogram
if none is registered. If aHistogram
was created, the providedMetadata
object will be registered.Note: During retrieval or creation, if a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Parameters:
metadata
- the name of the metrictags
- the tags of the metric- Returns:
- a new or pre-existing
Histogram
- Since:
- 2.0
-
meter
public abstract Meter meter(java.lang.String name)
Return theMeter
registered under theMetricID
with this name and with no tags; or create and register a newMeter
if none is registered. If aMeter
was created, aMetadata
object will be registered with the name and type. If aMetadata
object is already registered with this metric name then thatMetadata
will be used.- Parameters:
name
- the name of the metric- Returns:
- a new or pre-existing
Meter
-
meter
public abstract Meter meter(java.lang.String name, Tag... tags)
Return theMeter
registered under theMetricID
with this name and with the providedTag
s; or create and register a newMeter
if none is registered. If aMeter
was created, aMetadata
object will be registered with the name and type. If aMetadata
object is already registered with this metric name then thatMetadata
will be used.- Parameters:
name
- the name of the metrictags
- the tags of the metric- Returns:
- a new or pre-existing
Meter
- Since:
- 2.0
-
meter
public abstract Meter meter(Metadata metadata)
Return theMeter
registered under theMetricID
with theMetadata
's name and with no tags; or create and register a newMeter
if none is registered. If aMeter
was created, the providedMetadata
object will be registered.Note: During retrieval or creation, if a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Parameters:
metadata
- the name of the metric- Returns:
- a new or pre-existing
Meter
-
meter
public abstract Meter meter(Metadata metadata, Tag... tags)
Return theMeter
registered under theMetricID
with theMetadata
's name and with the providedTag
s; or create and register a newMeter
if none is registered. If aMeter
was created, the providedMetadata
object will be registered.Note: During retrieval or creation, if a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Parameters:
metadata
- the name of the metrictags
- the tags of the metric- Returns:
- a new or pre-existing
Meter
- Since:
- 2.0
-
timer
public abstract Timer timer(java.lang.String name)
Return theTimer
registered under theMetricID
with this name and with no tags; or create and register a newTimer
if none is registered. If aTimer
was created, aMetadata
object will be registered with the name and type. If aMetadata
object is already registered with this metric name then thatMetadata
will be used.- Parameters:
name
- the name of the metric- Returns:
- a new or pre-existing
Timer
-
timer
public abstract Timer timer(java.lang.String name, Tag... tags)
Return theTimer
registered under theMetricID
with this name and with the providedTag
s; or create and register a newTimer
if none is registered. If aTimer
was created, aMetadata
object will be registered with the name and type. If aMetadata
object is already registered with this metric name then thatMetadata
will be used.- Parameters:
name
- the name of the metrictags
- the tags of the metric- Returns:
- a new or pre-existing
Timer
- Since:
- 2.0
-
timer
public abstract Timer timer(Metadata metadata)
Return theTimer
registered under the theMetricID
with theMetadata
's name and with no tags; or create and register a newTimer
if none is registered. If aTimer
was created, the providedMetadata
object will be registered.Note: During retrieval or creation, if a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Parameters:
metadata
- the name of the metric- Returns:
- a new or pre-existing
Timer
-
timer
public abstract Timer timer(Metadata metadata, Tag... tags)
Return theTimer
registered under the theMetricID
with theMetadata
's name and with the providedTag
s; or create and register a newTimer
if none is registered. If aTimer
was created, the providedMetadata
object will be registered.Note: During retrieval or creation, if a
Metadata
object is already registered under this metric name and is not equal to the providedMetadata
object then an exception will be thrown.- Parameters:
metadata
- the name of the metrictags
- the tags of the metric- Returns:
- a new or pre-existing
Timer
- Since:
- 2.0
-
remove
public abstract boolean remove(java.lang.String name)
Removes all metrics with the given name.- Parameters:
name
- the name of the metric- Returns:
- whether or not the metric was removed
-
remove
public abstract boolean remove(MetricID metricID)
Removes the metric with the given MetricID- Parameters:
metricID
- the MetricID of the metric- Returns:
- whether or not the metric was removed
- Since:
- 2.0
-
removeMatching
public abstract void removeMatching(MetricFilter filter)
Removes all metrics which match the given filter.- Parameters:
filter
- a filter
-
getNames
public abstract java.util.SortedSet<java.lang.String> getNames()
Returns a set of the names of all the metrics in the registry.- Returns:
- the names of all the metrics
-
getMetricIDs
public abstract java.util.SortedSet<MetricID> getMetricIDs()
Returns a set of theMetricID
s of all the metrics in the registry.- Returns:
- the MetricIDs of all the metrics
-
getGauges
public abstract java.util.SortedMap<MetricID,Gauge> getGauges()
Returns a map of all the gauges in the registry and theirMetricID
s.- Returns:
- all the gauges in the registry
-
getGauges
public abstract java.util.SortedMap<MetricID,Gauge> getGauges(MetricFilter filter)
Returns a map of all the gauges in the registry and theirMetricID
s which match the given filter.- Parameters:
filter
- the metric filter to match- Returns:
- all the gauges in the registry
-
getCounters
public abstract java.util.SortedMap<MetricID,Counter> getCounters()
Returns a map of all the counters in the registry and theirMetricID
s.- Returns:
- all the counters in the registry
-
getCounters
public abstract java.util.SortedMap<MetricID,Counter> getCounters(MetricFilter filter)
Returns a map of all the counters in the registry and theirMetricID
s which match the given filter.- Parameters:
filter
- the metric filter to match- Returns:
- all the counters in the registry
-
getConcurrentGauges
public abstract java.util.SortedMap<MetricID,ConcurrentGauge> getConcurrentGauges()
Returns a map of all the concurrent gauges in the registry and theirMetricID
s.- Returns:
- all the concurrent gauges in the registry
-
getConcurrentGauges
public abstract java.util.SortedMap<MetricID,ConcurrentGauge> getConcurrentGauges(MetricFilter filter)
Returns a map of all the concurrent gauges in the registry and theirMetricID
s which match the given filter.- Parameters:
filter
- the metric filter to match- Returns:
- all the concurrent gauges in the registry
-
getHistograms
public abstract java.util.SortedMap<MetricID,Histogram> getHistograms()
Returns a map of all the histograms in the registry and theirMetricID
s.- Returns:
- all the histograms in the registry
-
getHistograms
public abstract java.util.SortedMap<MetricID,Histogram> getHistograms(MetricFilter filter)
Returns a map of all the histograms in the registry and theirMetricID
s which match the given filter.- Parameters:
filter
- the metric filter to match- Returns:
- all the histograms in the registry
-
getMeters
public abstract java.util.SortedMap<MetricID,Meter> getMeters()
Returns a map of all the meters in the registry and theirMetricID
s.- Returns:
- all the meters in the registry
-
getMeters
public abstract java.util.SortedMap<MetricID,Meter> getMeters(MetricFilter filter)
Returns a map of all the meters in the registry and theirMetricID
s which match the given filter.- Parameters:
filter
- the metric filter to match- Returns:
- all the meters in the registry
-
getTimers
public abstract java.util.SortedMap<MetricID,Timer> getTimers()
Returns a map of all the timers in the registry and theirMetricID
s.- Returns:
- all the timers in the registry
-
getTimers
public abstract java.util.SortedMap<MetricID,Timer> getTimers(MetricFilter filter)
Returns a map of all the timers in the registry and theirMetricID
s which match the given filter.- Parameters:
filter
- the metric filter to match- Returns:
- all the timers in the registry
-
getMetrics
public abstract java.util.Map<MetricID,Metric> getMetrics()
Returns a map of all the metrics in the registry and theirMetricID
s.- Returns:
- all the metrics in the registry
-
getMetadata
public abstract java.util.Map<java.lang.String,Metadata> getMetadata()
Returns a map of all the metadata in the registry and their names.- Returns:
- all the metadata in the registry
-
-