Interface MetricRegistry
-
public interface MetricRegistry
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 Interface Description static class
MetricRegistry.Type
An enumeration representing the scopes of the MetricRegistry
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description ConcurrentGauge
concurrentGauge(java.lang.String name)
Return theConcurrentGauge
registered under theMetricID
with this name; or create and register a newConcurrentGauge
if none is registered.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.ConcurrentGauge
concurrentGauge(Metadata metadata)
Return theConcurrentGauge
registered under theMetricID
with theMetadata
's name; or create and register a newConcurrentGauge
if none is registered.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.ConcurrentGauge
concurrentGauge(MetricID metricID)
Return theConcurrentGauge
registered under theMetricID
; or create and register a newConcurrentGauge
if none is registered.Counter
counter(java.lang.String name)
Counter
counter(java.lang.String name, Tag... tags)
Counter
counter(Metadata metadata)
Counter
counter(Metadata metadata, Tag... tags)
Counter
counter(MetricID metricID)
<T extends java.lang.Number>
Gauge<T>gauge(java.lang.String name, java.util.function.Supplier<T> supplier, Tag... tags)
<T,R extends java.lang.Number>
Gauge<R>gauge(java.lang.String name, T object, java.util.function.Function<T,R> func, Tag... tags)
<T extends java.lang.Number>
Gauge<T>gauge(Metadata metadata, java.util.function.Supplier<T> supplier, Tag... tags)
<T,R extends java.lang.Number>
Gauge<R>gauge(Metadata metadata, T object, java.util.function.Function<T,R> func, Tag... tags)
<T extends java.lang.Number>
Gauge<T>gauge(MetricID metricID, java.util.function.Supplier<T> supplier)
<T,R extends java.lang.Number>
Gauge<R>gauge(MetricID metricID, T object, java.util.function.Function<T,R> func)
ConcurrentGauge
getConcurrentGauge(MetricID metricID)
Return theConcurrentGauge
registered for the providedMetricID
.java.util.SortedMap<MetricID,ConcurrentGauge>
getConcurrentGauges()
Returns a map of all the concurrent gauges in the registry and theirMetricID
s.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.Counter
getCounter(MetricID metricID)
java.util.SortedMap<MetricID,Counter>
getCounters()
Returns a map of all the counters in the registry and theirMetricID
s.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.Gauge<?>
getGauge(MetricID metricID)
java.util.SortedMap<MetricID,Gauge>
getGauges()
Returns a map of all the gauges in the registry and theirMetricID
s.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.Histogram
getHistogram(MetricID metricID)
java.util.SortedMap<MetricID,Histogram>
getHistograms()
Returns a map of all the histograms in the registry and theirMetricID
s.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.java.util.Map<java.lang.String,Metadata>
getMetadata()
Returns a map of all the metadata in the registry and their names.Metadata
getMetadata(java.lang.String name)
Return theMetadata
for the provided name.Meter
getMeter(MetricID metricID)
java.util.SortedMap<MetricID,Meter>
getMeters()
Returns a map of all the meters in the registry and theirMetricID
s.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.Metric
getMetric(MetricID metricID)
<T extends Metric>
TgetMetric(MetricID metricID, java.lang.Class<T> asType)
java.util.SortedSet<MetricID>
getMetricIDs()
Returns a set of theMetricID
s of all the metrics in the registry.java.util.Map<MetricID,Metric>
getMetrics()
Returns a map of all the metrics in the registry and theirMetricID
s at query time.<T extends Metric>
java.util.SortedMap<MetricID,T>getMetrics(java.lang.Class<T> ofType, MetricFilter filter)
Returns a map of all the metrics in the registry and theirMetricID
s which match the given filter and which are assignable to the provided type.java.util.SortedMap<MetricID,Metric>
getMetrics(MetricFilter filter)
Returns a map of all the metrics in the registry and theirMetricID
s which match the given filter.java.util.SortedSet<java.lang.String>
getNames()
Returns a set of the names of all the metrics in the registry.SimpleTimer
getSimpleTimer(MetricID metricID)
Return theSimpleTimer
registered for the providedMetricID
.java.util.SortedMap<MetricID,SimpleTimer>
getSimpleTimers()
Returns a map of all the simple timers in the registry and theirMetricID
s.java.util.SortedMap<MetricID,SimpleTimer>
getSimpleTimers(MetricFilter filter)
Returns a map of all the simple timers in the registry and theirMetricID
s which match the given filter.Timer
getTimer(MetricID metricID)
java.util.SortedMap<MetricID,Timer>
getTimers()
Returns a map of all the timers in the registry and theirMetricID
s.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.MetricRegistry.Type
getType()
Returns the type of this metric registry.Histogram
histogram(java.lang.String name)
Histogram
histogram(java.lang.String name, Tag... tags)
Histogram
histogram(Metadata metadata)
Histogram
histogram(Metadata metadata, Tag... tags)
Histogram
histogram(MetricID metricID)
Meter
meter(java.lang.String name)
Meter
meter(java.lang.String name, Tag... tags)
Meter
meter(Metadata metadata)
Meter
meter(Metadata metadata, Tag... tags)
Meter
meter(MetricID metricID)
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.<T extends Metric>
Tregister(java.lang.String name, T metric)
<T extends Metric>
Tregister(Metadata metadata, T metric)
<T extends Metric>
Tregister(Metadata metadata, T metric, Tag... tags)
boolean
remove(java.lang.String name)
Removes all metrics with the given name.boolean
remove(MetricID metricID)
Removes the metric with the given MetricIDvoid
removeMatching(MetricFilter filter)
Removes all metrics which match the given filter.SimpleTimer
simpleTimer(java.lang.String name)
Return theSimpleTimer
registered under theMetricID
with this name and with no tags; or create and register a newSimpleTimer
if none is registered.SimpleTimer
simpleTimer(java.lang.String name, Tag... tags)
Return theSimpleTimer
registered under theMetricID
with this name and with the providedTag
s; or create and register a newSimpleTimer
if none is registered.SimpleTimer
simpleTimer(Metadata metadata)
Return theSimpleTimer
registered under the theMetricID
with theMetadata
's name and with no tags; or create and register a newSimpleTimer
if none is registered.SimpleTimer
simpleTimer(Metadata metadata, Tag... tags)
Return theSimpleTimer
registered under the theMetricID
with theMetadata
's name and with the providedTag
s; or create and register a newSimpleTimer
if none is registered.SimpleTimer
simpleTimer(MetricID metricID)
Return theSimpleTimer
registered under theMetricID
; or create and register a newSimpleTimer
if none is registered.Timer
timer(java.lang.String name)
Timer
timer(java.lang.String name, Tag... tags)
Timer
timer(Metadata metadata)
Timer
timer(Metadata metadata, Tag... tags)
Timer
timer(MetricID metricID)
-
-
-
Method Detail
-
name
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
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
<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
<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
<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
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
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
Counter counter(MetricID metricID)
Return theCounter
registered under theMetricID
; 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:
metricID
- the ID of the metric- Returns:
- a new or pre-existing
Counter
- Since:
- 3.0
-
counter
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
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
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
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
ConcurrentGauge concurrentGauge(MetricID metricID)
Return theConcurrentGauge
registered under theMetricID
; 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:
metricID
- the ID of the metric- Returns:
- a new or pre-existing
ConcurrentGauge
- Since:
- 3.0
-
concurrentGauge
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
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
-
gauge
<T,R extends java.lang.Number> Gauge<R> gauge(java.lang.String name, T object, java.util.function.Function<T,R> func, Tag... tags)
Return theGauge
of typeNumber
registered under theMetricID
with this name and with the providedTag
s; or create and register this gauge if none is registered. If aGauge
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. The createdGauge
will apply aFunction
to the provided object to resolve aNumber
value.- Type Parameters:
T
- The Type of the Object of which the functionfunc
is applied toR
- ANumber
- Parameters:
name
- The name of the Gauge metricobject
- The object that theFunction
func
will be applied tofunc
- TheFunction
that will be applied toobject
tags
- The tags of the metric- Returns:
- a new or pre-existing
Gauge
- Since:
- 3.0
-
gauge
<T,R extends java.lang.Number> Gauge<R> gauge(MetricID metricID, T object, java.util.function.Function<T,R> func)
Return theGauge
of typeNumber
registered under theMetricID
; or create and register this gauge if none is registered. If aGauge
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. The createdGauge
will apply aFunction
to the provided object to resolve aNumber
value.- Type Parameters:
T
- The Type of the Object of which the functionfunc
is applied toR
- ANumber
- Parameters:
metricID
- The MetricID of the Gauge metricobject
- The object that theFunction
func
will be applied tofunc
- TheFunction
that will be applied toobject
- Returns:
- a new or pre-existing
Gauge
- Since:
- 3.0
-
gauge
<T,R extends java.lang.Number> Gauge<R> gauge(Metadata metadata, T object, java.util.function.Function<T,R> func, Tag... tags)
Return theGauge
of typeNumber
registered under theMetricID
with the @{link Metadata}'s name and with the providedTag
s; or create and register this gauge if none is registered. If aGauge
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. The createdGauge
will apply aFunction
to the provided object to resolve aNumber
value.- Type Parameters:
T
- The Type of the Object of which the functionfunc
is applied toR
- ANumber
- Parameters:
metadata
- The Metadata of the Gaugeobject
- The object that theFunction
func
will be applied tofunc
- TheFunction
that will be applied toobject
tags
- The tags of the metric- Returns:
- a new or pre-existing
Gauge
- Since:
- 3.0
-
gauge
<T extends java.lang.Number> Gauge<T> gauge(java.lang.String name, java.util.function.Supplier<T> supplier, Tag... tags)
Return theGauge
registered under theMetricID
with this name and with the providedTag
s; or create and register this gauge if none is registered. If aGauge
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. The createdGauge
will return the value that theSupplier
will provide.- Type Parameters:
T
- ANumber
- Parameters:
name
- The name of the Gaugesupplier
- TheSupplier
function that will return the value for the Gauge metrictags
- The tags of the metric- Returns:
- a new or pre-existing
Gauge
- Since:
- 3.0
-
gauge
<T extends java.lang.Number> Gauge<T> gauge(MetricID metricID, java.util.function.Supplier<T> supplier)
Return theGauge
registered under theMetricID
; or create and register this gauge if none is registered. If aGauge
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. The createdGauge
will return the value that theSupplier
will provide.
-
gauge
<T extends java.lang.Number> Gauge<T> gauge(Metadata metadata, java.util.function.Supplier<T> supplier, Tag... tags)
Return theGauge
registered under theMetricID
with the @{link Metadata}'s name and with the providedTag
s; or create and register this gauge if none is registered. If aGauge
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. The createdGauge
will return the value that theSupplier
will provide.- Type Parameters:
T
- ANumber
- Parameters:
metadata
- The metadata of the gaugesupplier
- TheSupplier
function that will return the value for the Gauge metrictags
- The tags of the metric- Returns:
- a new or pre-existing
Gauge
- Since:
- 3.0
-
histogram
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
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
Histogram histogram(MetricID metricID)
Return theHistogram
registered under theMetricID
; 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:
metricID
- the ID of the metric- Returns:
- a new or pre-existing
Histogram
- Since:
- 3.0
-
histogram
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
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
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
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
Meter meter(MetricID metricID)
Return theMeter
registered under theMetricID
; 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:
metricID
- the ID of the metric- Returns:
- a new or pre-existing
Meter
- Since:
- 3.0
-
meter
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
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
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
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
Timer timer(MetricID metricID)
Return theTimer
registered under theMetricID
; 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:
metricID
- the ID of the metric- Returns:
- a new or pre-existing
Timer
- Since:
- 3.0
-
timer
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
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
-
simpleTimer
SimpleTimer simpleTimer(java.lang.String name)
Return theSimpleTimer
registered under theMetricID
with this name and with no tags; or create and register a newSimpleTimer
if none is registered. If aSimpleTimer
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
SimpleTimer
- Since:
- 2.3
-
simpleTimer
SimpleTimer simpleTimer(java.lang.String name, Tag... tags)
Return theSimpleTimer
registered under theMetricID
with this name and with the providedTag
s; or create and register a newSimpleTimer
if none is registered. If aSimpleTimer
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
SimpleTimer
- Since:
- 2.3
-
simpleTimer
SimpleTimer simpleTimer(MetricID metricID)
Return theSimpleTimer
registered under theMetricID
; or create and register a newSimpleTimer
if none is registered. If aSimpleTimer
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:
metricID
- the ID of the metric- Returns:
- a new or pre-existing
SimpleTimer
- Since:
- 3.0
-
simpleTimer
SimpleTimer simpleTimer(Metadata metadata)
Return theSimpleTimer
registered under the theMetricID
with theMetadata
's name and with no tags; or create and register a newSimpleTimer
if none is registered. If aSimpleTimer
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
SimpleTimer
- Since:
- 2.3
-
simpleTimer
SimpleTimer simpleTimer(Metadata metadata, Tag... tags)
Return theSimpleTimer
registered under the theMetricID
with theMetadata
's name and with the providedTag
s; or create and register a newSimpleTimer
if none is registered. If aSimpleTimer
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
SimpleTimer
- Since:
- 2.3
-
getMetric
<T extends Metric> T getMetric(MetricID metricID, java.lang.Class<T> asType)
- Parameters:
metricID
- lookup key, notnull
asType
- the return type which is expected to be compatible with the actual type of the registered metric- Returns:
- the
Metric
registered for the providedMetricID
ornull
if none has been registered so far - Throws:
java.lang.IllegalArgumentException
- If the registered metric was not assignable to the provided type- Since:
- 3.0
-
getConcurrentGauge
ConcurrentGauge getConcurrentGauge(MetricID metricID)
Return theConcurrentGauge
registered for the providedMetricID
.- Parameters:
metricID
- lookup key, notnull
- Returns:
- the
ConcurrentGauge
registered for the key ornull
if none has been registered so far - Throws:
java.lang.IllegalArgumentException
- If the registered metric was not assignable toConcurrentGauge
- Since:
- 3.0
-
getSimpleTimer
SimpleTimer getSimpleTimer(MetricID metricID)
Return theSimpleTimer
registered for the providedMetricID
.- Parameters:
metricID
- lookup key, notnull
- Returns:
- the
SimpleTimer
registered for the key ornull
if none has been registered so far - Throws:
java.lang.IllegalArgumentException
- If the registered metric was not assignable toSimpleTimer
- Since:
- 3.0
-
getMetadata
Metadata getMetadata(java.lang.String name)
Return theMetadata
for the provided name.- Parameters:
name
- the name of the metric- Returns:
- the
Metadata
for the provided name ofnull
if none has been registered for that name - Since:
- 3.0
-
remove
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
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
void removeMatching(MetricFilter filter)
Removes all metrics which match the given filter.- Parameters:
filter
- a filter
-
getNames
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
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
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
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
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
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
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
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
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
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
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
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
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
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
-
getSimpleTimers
java.util.SortedMap<MetricID,SimpleTimer> getSimpleTimers()
Returns a map of all the simple timers in the registry and theirMetricID
s.- Returns:
- all the timers in the registry
-
getSimpleTimers
java.util.SortedMap<MetricID,SimpleTimer> getSimpleTimers(MetricFilter filter)
Returns a map of all the simple 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
java.util.SortedMap<MetricID,Metric> getMetrics(MetricFilter filter)
Returns a map of all the metrics in the registry and theirMetricID
s which match the given filter.- Parameters:
filter
- the metric filter to match- Returns:
- all the metrics in the registry
- Since:
- 3.0
-
getMetrics
<T extends Metric> java.util.SortedMap<MetricID,T> getMetrics(java.lang.Class<T> ofType, MetricFilter filter)
Returns a map of all the metrics in the registry and theirMetricID
s which match the given filter and which are assignable to the provided type.- Parameters:
ofType
- the type to which all returned metrics should be assignablefilter
- the metric filter to match- Returns:
- all the metrics in the registry
- Since:
- 3.0
-
getMetrics
java.util.Map<MetricID,Metric> getMetrics()
Returns a map of all the metrics in the registry and theirMetricID
s at query time. The only guarantee about this method is that any key has a value (compared to usinggetMetric(MetricID)
andgetMetricIDs()
together). It is only intended for bulk querying, if you need a single or a few entries, always prefergetMetric(MetricID)
orgetMetrics(MetricFilter)
.- Returns:
- all the metrics in the registry
-
getMetadata
java.util.Map<java.lang.String,Metadata> getMetadata()
Returns a map of all the metadata in the registry and their names. The only guarantee about this method is that any key has a value (compared to usinggetMetadata(String)
. It is only intended for bulk querying, if you need a single or a few metadata, always prefergetMetadata(String)
}.- Returns:
- all the metadata in the registry
-
getType
MetricRegistry.Type getType()
Returns the type of this metric registry.- Returns:
- Type of this registry (VENDOR, BASE, APPLICATION)
-
-