Interface MetricRegistry
-
public interface MetricRegistryThe 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 classMetricRegistry.TypeDeprecated.As of release 5.0, please useAPPLICATION_SCOPE,BASE_SCOPEorVENDOR_SCOPEwithRegistryScopeinstead.
-
Field Summary
Fields Modifier and Type Field Description static StringAPPLICATION_SCOPEString constant to represent the scope value used for the application scopestatic StringBASE_SCOPEString constant to represent the scope value used for the base scopestatic StringVENDOR_SCOPEString constant to represent the scope value used for the vendor scope
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Countercounter(String name)Countercounter(String name, Tag... tags)Countercounter(Metadata metadata)Countercounter(Metadata metadata, Tag... tags)Countercounter(MetricID metricID)<T extends Number>
Gauge<T>gauge(String name, Supplier<T> supplier, Tag... tags)<T,R extends Number>
Gauge<R>gauge(String name, T object, Function<T,R> func, Tag... tags)<T extends Number>
Gauge<T>gauge(Metadata metadata, Supplier<T> supplier, Tag... tags)<T,R extends Number>
Gauge<R>gauge(Metadata metadata, T object, Function<T,R> func, Tag... tags)<T extends Number>
Gauge<T>gauge(MetricID metricID, Supplier<T> supplier)<T,R extends Number>
Gauge<R>gauge(MetricID metricID, T object, Function<T,R> func)CountergetCounter(MetricID metricID)SortedMap<MetricID,Counter>getCounters()Returns a map of all the counters in the registry and theirMetricIDs.SortedMap<MetricID,Counter>getCounters(MetricFilter filter)Returns a map of all the counters in the registry and theirMetricIDs which match the given filter.Gauge<?>getGauge(MetricID metricID)SortedMap<MetricID,Gauge>getGauges()Returns a map of all the gauges in the registry and theirMetricIDs.SortedMap<MetricID,Gauge>getGauges(MetricFilter filter)Returns a map of all the gauges in the registry and theirMetricIDs which match the given filter.HistogramgetHistogram(MetricID metricID)SortedMap<MetricID,Histogram>getHistograms()Returns a map of all the histograms in the registry and theirMetricIDs.SortedMap<MetricID,Histogram>getHistograms(MetricFilter filter)Returns a map of all the histograms in the registry and theirMetricIDs which match the given filter.Map<String,Metadata>getMetadata()Returns a map of all the metadata in the registry and their names.MetadatagetMetadata(String name)Return theMetadatafor the provided name.MetricgetMetric(MetricID metricID)<T extends Metric>
TgetMetric(MetricID metricID, Class<T> asType)SortedSet<MetricID>getMetricIDs()Returns a set of theMetricIDs of all the metrics in the registry.Map<MetricID,Metric>getMetrics()Returns a map of all the metrics in the registry and theirMetricIDs at query time.<T extends Metric>
SortedMap<MetricID,T>getMetrics(Class<T> ofType, MetricFilter filter)Returns a map of all the metrics in the registry and theirMetricIDs which match the given filter and which are assignable to the provided type.SortedMap<MetricID,Metric>getMetrics(MetricFilter filter)Returns a map of all the metrics in the registry and theirMetricIDs which match the given filter.SortedSet<String>getNames()Returns a set of the names of all the metrics in the registry.StringgetScope()Returns the scope of this metric registry.TimergetTimer(MetricID metricID)SortedMap<MetricID,Timer>getTimers()Returns a map of all the timers in the registry and theirMetricIDs.SortedMap<MetricID,Timer>getTimers(MetricFilter filter)Returns a map of all the timers in the registry and theirMetricIDs which match the given filter.Histogramhistogram(String name)Histogramhistogram(String name, Tag... tags)Histogramhistogram(Metadata metadata)Histogramhistogram(Metadata metadata, Tag... tags)Histogramhistogram(MetricID metricID)static Stringname(Class<?> klass, String... names)Concatenates a class name and elements to form a dotted name, eliding any null values or empty strings.static Stringname(String name, String... names)Concatenates elements to form a dotted name, eliding any null values or empty strings.booleanremove(String name)Removes all metrics with the given name.booleanremove(MetricID metricID)Removes the metric with the given MetricIDvoidremoveMatching(MetricFilter filter)Removes all metrics which match the given filter.Timertimer(String name)Timertimer(String name, Tag... tags)Timertimer(Metadata metadata)Timertimer(Metadata metadata, Tag... tags)Timertimer(MetricID metricID)
-
-
-
Field Detail
-
APPLICATION_SCOPE
static final String APPLICATION_SCOPE
String constant to represent the scope value used for the application scope- See Also:
- Constant Field Values
-
VENDOR_SCOPE
static final String VENDOR_SCOPE
String constant to represent the scope value used for the vendor scope- See Also:
- Constant Field Values
-
BASE_SCOPE
static final String BASE_SCOPE
String constant to represent the scope value used for the base scope- See Also:
- Constant Field Values
-
-
Method Detail
-
name
static String name(String name, 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:
nameandnamesconcatenated by periods
-
name
static String name(Class<?> klass, 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:
klassandnamesconcatenated by periods
-
counter
Counter counter(String name)
Return theCounterregistered under theMetricIDwith this name and with no tags; or create and register a newCounterif none is registered. If aCounterwas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill be used.- Parameters:
name- the name of the metric- Returns:
- a new or pre-existing
Counter
-
counter
Counter counter(String name, Tag... tags)
Return theCounterregistered under theMetricIDwith this name and with the providedTags; or create and register a newCounterif none is registered. If aCounterwas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill 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 theCounterregistered under theMetricID; or create and register a newCounterif none is registered. If aCounterwas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill 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 theCounterregistered under theMetricIDwith theMetadata's name and with no tags; or create and register a newCounterif none is registered. If aCounterwas created, the providedMetadataobject will be registered.Note: During retrieval or creation, if a
Metadataobject is already registered under this metric name and is not equal to the providedMetadataobject 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 theCounterregistered under theMetricIDwith theMetadata's name and with the providedTags; or create and register a newCounterif none is registered. If aCounterwas created, the providedMetadataobject will be registered.Note: During retrieval or creation, if a
Metadataobject is already registered under this metric name and is not equal to the providedMetadataobject 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
-
gauge
<T,R extends Number> Gauge<R> gauge(String name, T object, Function<T,R> func, Tag... tags)
Return theGaugeof typeNumberregistered under theMetricIDwith this name and with the providedTags; or create and register this gauge if none is registered. If aGaugewas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill be used. The createdGaugewill apply aFunctionto the provided object to resolve aNumbervalue.- Type Parameters:
T- The Type of the Object of which the functionfuncis applied toR- ANumber- Parameters:
name- The name of the Gauge metricobject- The object that theFunctionfuncwill be applied tofunc- TheFunctionthat will be applied toobjecttags- The tags of the metric- Returns:
- a new or pre-existing
Gauge - Since:
- 3.0
-
gauge
<T,R extends Number> Gauge<R> gauge(MetricID metricID, T object, Function<T,R> func)
Return theGaugeof typeNumberregistered under theMetricID; or create and register this gauge if none is registered. If aGaugewas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill be used. The createdGaugewill apply aFunctionto the provided object to resolve aNumbervalue.- Type Parameters:
T- The Type of the Object of which the functionfuncis applied toR- ANumber- Parameters:
metricID- The MetricID of the Gauge metricobject- The object that theFunctionfuncwill be applied tofunc- TheFunctionthat will be applied toobject- Returns:
- a new or pre-existing
Gauge - Since:
- 3.0
-
gauge
<T,R extends Number> Gauge<R> gauge(Metadata metadata, T object, Function<T,R> func, Tag... tags)
Return theGaugeof typeNumberregistered under theMetricIDwith the @{link Metadata}'s name and with the providedTags; or create and register this gauge if none is registered. If aGaugewas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill be used. The createdGaugewill apply aFunctionto the provided object to resolve aNumbervalue.- Type Parameters:
T- The Type of the Object of which the functionfuncis applied toR- ANumber- Parameters:
metadata- The Metadata of the Gaugeobject- The object that theFunctionfuncwill be applied tofunc- TheFunctionthat will be applied toobjecttags- The tags of the metric- Returns:
- a new or pre-existing
Gauge - Since:
- 3.0
-
gauge
<T extends Number> Gauge<T> gauge(String name, Supplier<T> supplier, Tag... tags)
Return theGaugeregistered under theMetricIDwith this name and with the providedTags; or create and register this gauge if none is registered. If aGaugewas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill be used. The createdGaugewill return the value that theSupplierwill provide.
-
gauge
<T extends Number> Gauge<T> gauge(MetricID metricID, Supplier<T> supplier)
Return theGaugeregistered under theMetricID; or create and register this gauge if none is registered. If aGaugewas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill be used. The createdGaugewill return the value that theSupplierwill provide.
-
gauge
<T extends Number> Gauge<T> gauge(Metadata metadata, Supplier<T> supplier, Tag... tags)
Return theGaugeregistered under theMetricIDwith the @{link Metadata}'s name and with the providedTags; or create and register this gauge if none is registered. If aGaugewas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill be used. The createdGaugewill return the value that theSupplierwill provide.
-
histogram
Histogram histogram(String name)
Return theHistogramregistered under theMetricIDwith this name and with no tags; or create and register a newHistogramif none is registered. If aHistogramwas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill be used.- Parameters:
name- the name of the metric- Returns:
- a new or pre-existing
Histogram
-
histogram
Histogram histogram(String name, Tag... tags)
Return theHistogramregistered under theMetricIDwith this name and with the providedTags; or create and register a newHistogramif none is registered. If aHistogramwas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill 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 theHistogramregistered under theMetricID; or create and register a newHistogramif none is registered. If aHistogramwas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill 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 theHistogramregistered under theMetricIDwith theMetadata's name and with no tags; or create and register a newHistogramif none is registered. If aHistogramwas created, the providedMetadataobject will be registered.Note: During retrieval or creation, if a
Metadataobject is already registered under this metric name and is not equal to the providedMetadataobject 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 theHistogramregistered under theMetricIDwith theMetadata's name and with the providedTags; or create and register a newHistogramif none is registered. If aHistogramwas created, the providedMetadataobject will be registered.Note: During retrieval or creation, if a
Metadataobject is already registered under this metric name and is not equal to the providedMetadataobject 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
-
timer
Timer timer(String name)
Return theTimerregistered under theMetricIDwith this name and with no tags; or create and register a newTimerif none is registered. If aTimerwas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill be used.- Parameters:
name- the name of the metric- Returns:
- a new or pre-existing
Timer
-
timer
Timer timer(String name, Tag... tags)
Return theTimerregistered under theMetricIDwith this name and with the providedTags; or create and register a newTimerif none is registered. If aTimerwas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill 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 theTimerregistered under theMetricID; or create and register a newTimerif none is registered. If aTimerwas created, aMetadataobject will be registered with the name and type. If aMetadataobject is already registered with this metric name then thatMetadatawill 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 theTimerregistered under the theMetricIDwith theMetadata's name and with no tags; or create and register a newTimerif none is registered. If aTimerwas created, the providedMetadataobject will be registered.Note: During retrieval or creation, if a
Metadataobject is already registered under this metric name and is not equal to the providedMetadataobject 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 theTimerregistered under the theMetricIDwith theMetadata's name and with the providedTags; or create and register a newTimerif none is registered. If aTimerwas created, the providedMetadataobject will be registered.Note: During retrieval or creation, if a
Metadataobject is already registered under this metric name and is not equal to the providedMetadataobject 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
-
getMetric
<T extends Metric> T getMetric(MetricID metricID, Class<T> asType)
- Parameters:
metricID- lookup key, notnullasType- the return type which is expected to be compatible with the actual type of the registered metric- Returns:
- the
Metricregistered for the providedMetricIDornullif none has been registered so far - Throws:
IllegalArgumentException- If the registered metric was not assignable to the provided type- Since:
- 3.0
-
getCounter
Counter getCounter(MetricID metricID)
- Parameters:
metricID- lookup key, notnull- Returns:
- the
Counterregistered for the key ornullif none has been registered so far - Throws:
IllegalArgumentException- If the registered metric was not assignable toCounter- Since:
- 3.0
-
getGauge
Gauge<?> getGauge(MetricID metricID)
- Parameters:
metricID- lookup key, notnull- Returns:
- the
Gaugeregistered for the key ornullif none has been registered so far - Throws:
IllegalArgumentException- If the registered metric was not assignable toGauge- Since:
- 3.0
-
getHistogram
Histogram getHistogram(MetricID metricID)
- Parameters:
metricID- lookup key, notnull- Returns:
- the
Histogramregistered for the key ornullif none has been registered so far - Throws:
IllegalArgumentException- If the registered metric was not assignable toHistogram- Since:
- 3.0
-
getTimer
Timer getTimer(MetricID metricID)
- Parameters:
metricID- lookup key, notnull- Returns:
- the
Timerregistered for the key ornullif none has been registered so far - Throws:
IllegalArgumentException- If the registered metric was not assignable toTimer- Since:
- 3.0
-
getMetadata
Metadata getMetadata(String name)
Return theMetadatafor the provided name.- Parameters:
name- the name of the metric- Returns:
- the
Metadatafor the provided name ornullif none has been registered for that name - Since:
- 3.0
-
remove
boolean remove(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
SortedSet<String> getNames()
Returns a set of the names of all the metrics in the registry.- Returns:
- the names of all the metrics
-
getMetricIDs
SortedSet<MetricID> getMetricIDs()
Returns a set of theMetricIDs of all the metrics in the registry.- Returns:
- the MetricIDs of all the metrics
-
getGauges
SortedMap<MetricID,Gauge> getGauges()
Returns a map of all the gauges in the registry and theirMetricIDs.- Returns:
- all the gauges in the registry
-
getGauges
SortedMap<MetricID,Gauge> getGauges(MetricFilter filter)
Returns a map of all the gauges in the registry and theirMetricIDs which match the given filter.- Parameters:
filter- the metric filter to match- Returns:
- all the gauges in the registry
-
getCounters
SortedMap<MetricID,Counter> getCounters()
Returns a map of all the counters in the registry and theirMetricIDs.- Returns:
- all the counters in the registry
-
getCounters
SortedMap<MetricID,Counter> getCounters(MetricFilter filter)
Returns a map of all the counters in the registry and theirMetricIDs which match the given filter.- Parameters:
filter- the metric filter to match- Returns:
- all the counters in the registry
-
getHistograms
SortedMap<MetricID,Histogram> getHistograms()
Returns a map of all the histograms in the registry and theirMetricIDs.- Returns:
- all the histograms in the registry
-
getHistograms
SortedMap<MetricID,Histogram> getHistograms(MetricFilter filter)
Returns a map of all the histograms in the registry and theirMetricIDs which match the given filter.- Parameters:
filter- the metric filter to match- Returns:
- all the histograms in the registry
-
getTimers
SortedMap<MetricID,Timer> getTimers()
Returns a map of all the timers in the registry and theirMetricIDs.- Returns:
- all the timers in the registry
-
getTimers
SortedMap<MetricID,Timer> getTimers(MetricFilter filter)
Returns a map of all the timers in the registry and theirMetricIDs which match the given filter.- Parameters:
filter- the metric filter to match- Returns:
- all the timers in the registry
-
getMetrics
SortedMap<MetricID,Metric> getMetrics(MetricFilter filter)
Returns a map of all the metrics in the registry and theirMetricIDs 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> SortedMap<MetricID,T> getMetrics(Class<T> ofType, MetricFilter filter)
Returns a map of all the metrics in the registry and theirMetricIDs 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
Map<MetricID,Metric> getMetrics()
Returns a map of all the metrics in the registry and theirMetricIDs 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
Map<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
-
getScope
String getScope()
Returns the scope of this metric registry.- Returns:
- Scope of this registry (VENDOR_SCOPE, BASE_SCOPE, APPLICATION_SCOPE, or a custom scope)
-
-