Class AbstractRegistry<M extends HelidonMetric>
- Type Parameters:
M- general type of metric implementation supported by an implementation of this class (e.g.,HelidonMetric
- All Implemented Interfaces:
MetricRegistry
- Direct Known Subclasses:
Registry
This class provides the bookkeeping for tracking the metrics which are created and registered along with their IDs and metadata. Concrete subclasses create new instances of the various types of metrics (counter, timer, etc.).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceGauge factories based on either functions or suppliers.Nested classes/interfaces inherited from interface org.eclipse.microprofile.metrics.MetricRegistry
MetricRegistry.Type -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRegistry(MetricRegistry.Type type, Class<M> metricClass, RegistrySettings registrySettings) Create a registry of a certain type. -
Method Summary
Modifier and TypeMethodDescriptionconcurrentGauge(String name) concurrentGauge(String name, Tag... tags) concurrentGauge(Metadata metadata) concurrentGauge(Metadata metadata, Tag... tags) concurrentGauge(MetricID metricID) createGauge(Metadata metadata, Supplier<R> supplier) Creates a gauge instance according to the specified supplier which returns the gauge value.createGauge(Metadata metadata, T object, Function<T, R> func) Creates a gauge instance according to the provided metadata such that retrievals of the gauge value trigger an invocation of the provided function, passing the indicated object.protected static MetricTypederiveType(MetricType candidateType, Metric metric) Infers theMetricTypefrom a provided candidate type and a metric instance.booleanempty()Determines if registry is empty.getConcurrentGauge(MetricID metricID) getConcurrentGauges(MetricFilter filter) getCounter(MetricID metricID) getCounters(MetricFilter filter) Gauge<?>getGauges(MetricFilter filter) getHistogram(MetricID metricID) getHistograms(MetricFilter filter) getMetadata(String name) getMeters(MetricFilter filter) <T extends Metric>
TgetMetrics(Class<T> ofType, MetricFilter filter) getMetrics(MetricFilter filter) getMetricsByName(String metricName) Returns a list of metric ID/metric pairs which match the provided metric name.getNames()getOptionalMetricEntry(String metricName) Returns anOptionalfor an entry containing a metric ID and the corresponding metric matching the specified metric name.getSimpleTimer(MetricID metricID) getSimpleTimers(MetricFilter filter) getTimers(MetricFilter filter) getType()static booleanisMarkedAsDeleted(Metric metric) Indicates whether the specific metrics has been marked as deleted.protected abstract booleanisMetricEnabled(String metricName) Indicates whether the specified metric name is enabled or not.protected booleanmetadataWithIDs(String metricName) Returns a map entry, its key the metadata and its value all metric IDs matching the provided metric name.protected Map<MetricType,BiFunction<String, Metadata, M>> For testing.metricIDsForName(String metricName) Returns a list of metric IDs given a metric name.protected abstract Map<MetricType,BiFunction<String, Metadata, M>> Provides a map from MicroProfile metric type to a factory which creates a concrete metric instance of the MP metric type which also extends the implementation metric base class for the concrete implementation (e.g., no-op or full-featured).protected abstract Map<Class<? extends M>,MetricType> Prepares the map from Java types of implementation metrics to the correspondingMetricType.<T extends Metric>
T<T extends Metric>
T<T extends Metric>
TbooleanRemoves a metric by name.booleanRemoves a metric by ID.voidremoveMatching(MetricFilter filter) simpleTimer(String name) simpleTimer(String name, Tag... tags) simpleTimer(Metadata metadata) simpleTimer(Metadata metadata, Tag... tags) simpleTimer(MetricID metricID) stream()Returns a stream ofMap.Entryfor this registry for enabled metrics.Creates a new instance of an implementation wrapper around the indicated metric.toString()type()Returns type of this registry.voidupdate(RegistrySettings registrySettings) Update the registry settings for this registry.
-
Constructor Details
-
AbstractRegistry
protected AbstractRegistry(MetricRegistry.Type type, Class<M> metricClass, RegistrySettings registrySettings) Create a registry of a certain type.- Parameters:
type- Registry type.metricClass- class of the specific metric type this registry managesregistrySettings- registry settings which influence this registry
-
-
Method Details
-
isMarkedAsDeleted
Indicates whether the specific metrics has been marked as deleted.- Parameters:
metric- the metric to check- Returns:
- true if it's a Helidon metric and has been marked as deleted; false otherwise
-
isMetricEnabled
Indicates whether the specified metric name is enabled or not.Concrete implementations of this method should account for registry settings that might have disabled the specified metric or the registry as a whole. They do not need to check whether metrics in its entirety is enabled.
- Parameters:
metricName- name of the metric to check- Returns:
- true if the metric is enabled; false otherwise
-
register
- Specified by:
registerin interfaceMetricRegistry- Throws:
IllegalArgumentException
-
register
- Specified by:
registerin interfaceMetricRegistry- Throws:
IllegalArgumentException
-
register
public <T extends Metric> T register(Metadata metadata, T metric, Tag... tags) throws IllegalArgumentException - Specified by:
registerin interfaceMetricRegistry- Throws:
IllegalArgumentException
-
counter
- Specified by:
counterin interfaceMetricRegistry
-
counter
- Specified by:
counterin interfaceMetricRegistry
-
counter
- Specified by:
counterin interfaceMetricRegistry
-
counter
- Specified by:
counterin interfaceMetricRegistry
-
counter
- Specified by:
counterin interfaceMetricRegistry
-
getCounter
- Specified by:
getCounterin interfaceMetricRegistry
-
histogram
- Specified by:
histogramin interfaceMetricRegistry
-
histogram
- Specified by:
histogramin interfaceMetricRegistry
-
histogram
- Specified by:
histogramin interfaceMetricRegistry
-
histogram
- Specified by:
histogramin interfaceMetricRegistry
-
histogram
- Specified by:
histogramin interfaceMetricRegistry
-
getHistogram
- Specified by:
getHistogramin interfaceMetricRegistry
-
meter
- Specified by:
meterin interfaceMetricRegistry
-
meter
- Specified by:
meterin interfaceMetricRegistry
-
meter
- Specified by:
meterin interfaceMetricRegistry
-
meter
- Specified by:
meterin interfaceMetricRegistry
-
meter
- Specified by:
meterin interfaceMetricRegistry
-
getMeter
- Specified by:
getMeterin interfaceMetricRegistry
-
timer
- Specified by:
timerin interfaceMetricRegistry
-
timer
- Specified by:
timerin interfaceMetricRegistry
-
timer
- Specified by:
timerin interfaceMetricRegistry
-
timer
- Specified by:
timerin interfaceMetricRegistry
-
timer
- Specified by:
timerin interfaceMetricRegistry
-
getTimer
- Specified by:
getTimerin interfaceMetricRegistry
-
concurrentGauge
- Specified by:
concurrentGaugein interfaceMetricRegistry
-
concurrentGauge
- Specified by:
concurrentGaugein interfaceMetricRegistry
-
concurrentGauge
- Specified by:
concurrentGaugein interfaceMetricRegistry
-
concurrentGauge
- Specified by:
concurrentGaugein interfaceMetricRegistry
-
concurrentGauge
- Specified by:
concurrentGaugein interfaceMetricRegistry
-
getConcurrentGauge
- Specified by:
getConcurrentGaugein interfaceMetricRegistry
-
simpleTimer
- Specified by:
simpleTimerin interfaceMetricRegistry
-
simpleTimer
- Specified by:
simpleTimerin interfaceMetricRegistry
-
simpleTimer
- Specified by:
simpleTimerin interfaceMetricRegistry
-
simpleTimer
- Specified by:
simpleTimerin interfaceMetricRegistry
-
getSimpleTimer
- Specified by:
getSimpleTimerin interfaceMetricRegistry
-
simpleTimer
- Specified by:
simpleTimerin interfaceMetricRegistry
-
gauge
- Specified by:
gaugein interfaceMetricRegistry
-
gauge
- Specified by:
gaugein interfaceMetricRegistry
-
gauge
public <T,R extends Number> Gauge<R> gauge(Metadata metadata, T object, Function<T, R> func, Tag... tags) - Specified by:
gaugein interfaceMetricRegistry
-
gauge
- Specified by:
gaugein interfaceMetricRegistry
-
gauge
- Specified by:
gaugein interfaceMetricRegistry
-
gauge
- Specified by:
gaugein interfaceMetricRegistry
-
getGauge
- Specified by:
getGaugein interfaceMetricRegistry
-
remove
Removes a metric by name.- Specified by:
removein interfaceMetricRegistry- Parameters:
name- Name of the metric.- Returns:
- Outcome of removal.
-
remove
Removes a metric by ID.- Specified by:
removein interfaceMetricRegistry- Parameters:
metricID- ID of metric.- Returns:
- Outcome of removal.
-
removeMatching
- Specified by:
removeMatchingin interfaceMetricRegistry
-
getNames
- Specified by:
getNamesin interfaceMetricRegistry
-
getMetricIDs
- Specified by:
getMetricIDsin interfaceMetricRegistry
-
getGauges
- Specified by:
getGaugesin interfaceMetricRegistry
-
getGauges
- Specified by:
getGaugesin interfaceMetricRegistry
-
getCounters
- Specified by:
getCountersin interfaceMetricRegistry
-
getCounters
- Specified by:
getCountersin interfaceMetricRegistry
-
getHistograms
- Specified by:
getHistogramsin interfaceMetricRegistry
-
getHistograms
- Specified by:
getHistogramsin interfaceMetricRegistry
-
getMeters
- Specified by:
getMetersin interfaceMetricRegistry
-
getMeters
- Specified by:
getMetersin interfaceMetricRegistry
-
getTimers
- Specified by:
getTimersin interfaceMetricRegistry
-
getTimers
- Specified by:
getTimersin interfaceMetricRegistry
-
getConcurrentGauges
- Specified by:
getConcurrentGaugesin interfaceMetricRegistry
-
getConcurrentGauges
- Specified by:
getConcurrentGaugesin interfaceMetricRegistry
-
getSimpleTimers
- Specified by:
getSimpleTimersin interfaceMetricRegistry
-
getSimpleTimers
- Specified by:
getSimpleTimersin interfaceMetricRegistry
-
getMetadata
- Specified by:
getMetadatain interfaceMetricRegistry
-
getMetadata
- Specified by:
getMetadatain interfaceMetricRegistry
-
getMetrics
- Specified by:
getMetricsin interfaceMetricRegistry
-
getMetrics
- Specified by:
getMetricsin interfaceMetricRegistry
-
getMetrics
- Specified by:
getMetricsin interfaceMetricRegistry
-
getMetric
- Specified by:
getMetricin interfaceMetricRegistry
-
getMetric
- Specified by:
getMetricin interfaceMetricRegistry
-
update
Update the registry settings for this registry.- Parameters:
registrySettings- new settings to use going forward
-
type
Returns type of this registry.- Returns:
- The type.
-
getType
- Specified by:
getTypein interfaceMetricRegistry
-
empty
public boolean empty()Determines if registry is empty.- Returns:
- Outcome of test.
-
toString
-
metadataWithIDs
Returns a map entry, its key the metadata and its value all metric IDs matching the provided metric name.- Parameters:
metricName- name to search for- Returns:
- the metadata and metric IDs known for the specified metric name; null if the name is not registered
-
registrySettings
- Returns:
- the registry settings used to set up the registry
-
isStrictExemplars
protected boolean isStrictExemplars()- Returns:
- whether exemplars are to be implemented strictly
-
stream
Returns a stream ofMap.Entryfor this registry for enabled metrics.- Returns:
- Stream of
Map.Entry
-
toImpl
Creates a new instance of an implementation wrapper around the indicated metric.- Type Parameters:
T- specific type ofMetricprovided and wrapped- Parameters:
metadata-Metadatafor the metricmetric- the existing metric to be wrapped by the impl- Returns:
- new wrapper implementation around the specified metric instance
-
prepareMetricFactories
Provides a map from MicroProfile metric type to a factory which creates a concrete metric instance of the MP metric type which also extends the implementation metric base class for the concrete implementation (e.g., no-op or full-featured).- Returns:
- map from each MicroProfile metric type to the correspondingfactory method
-
getOptionalMetricEntry
Returns anOptionalfor an entry containing a metric ID and the corresponding metric matching the specified metric name.If multiple metrics match the name (because of tags), the returned metric is, preferentially, the one (if any) with no tags. If all metrics registered under the specified name have tags, then the method returns the metric which was registered earliest
- Parameters:
metricName- name of the metric of interest- Returns:
Optionalof a map entry containing the metric ID and the metric selected
-
getMetricsByName
Returns a list of metric ID/metric pairs which match the provided metric name.- Parameters:
metricName- name of the metric of interest- Returns:
- List of entries indicating metrics with the specified name; empty of no matches
-
metricIDsForName
Returns a list of metric IDs given a metric name.- Parameters:
metricName- name of the metric of interest- Returns:
- list of metric IDs for metrics with the specified name; empty if no matches
-
createGauge
protected <T,R extends Number> Gauge<R> createGauge(Metadata metadata, T object, Function<T, R> func) Creates a gauge instance according to the provided metadata such that retrievals of the gauge value trigger an invocation of the provided function, passing the indicated object.This default implementation uses a capturing lambda for retrieving the value. Concrete subclasses can override this implementation if capturing lambda behavior might become a performance issue.
- Type Parameters:
T- Java type of the function parameter (and the object to pass to it)R- specificNumbersubtype the gauge reports- Parameters:
metadata- metadata to use in creating the gaugeobject- object to pass to the value-returning functionfunc- gauge-value-returning function- Returns:
- new gauge
-
createGauge
Creates a gauge instance according to the specified supplier which returns the gauge value.- Type Parameters:
R- specificNumbersubtype the supplier returns- Parameters:
metadata- metadata to use in creating the gaugesupplier- gauge-value-returning supplier- Returns:
- new gauge
-
deriveType
Infers theMetricTypefrom a provided candidate type and a metric instance.- Parameters:
candidateType- type of metric to use if not invalid; typically computed from an existing metricmetric- the metric for which to derive the metric type- Returns:
- the
MetricTypeof the metric
-
metricFactories
For testing.- Returns:
- map from MicroProfile metric type to factory functions.
-
prepareMetricToTypeMap
Prepares the map from Java types of implementation metrics to the correspondingMetricType.- Returns:
- prepared map for a given metrics implementation
-