Module io.helidon.metrics.api
Package io.helidon.metrics.api
Class AbstractRegistry<M extends HelidonMetric>
- java.lang.Object
-
- org.eclipse.microprofile.metrics.MetricRegistry
-
- io.helidon.metrics.api.AbstractRegistry<M>
-
- Type Parameters:
M
- general type of metric implementation supported by an implementation of this class (e.g.,HelidonMetric
- Direct Known Subclasses:
Registry
public abstract class AbstractRegistry<M extends HelidonMetric> extends MetricRegistry
Common behavior for any category (e.g., full-featured or no-op) metrics 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 classes/interfaces inherited from class org.eclipse.microprofile.metrics.MetricRegistry
MetricRegistry.Type
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractRegistry(MetricRegistry.Type type, Class<M> metricClass, RegistrySettings registrySettings)
Create a registry of a certain type.
-
Method Summary
-
Methods inherited from class org.eclipse.microprofile.metrics.MetricRegistry
name, name
-
-
-
-
Constructor Detail
-
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
- settings for configuring the registry
-
-
Method Detail
-
isMarkedAsDeleted
public static boolean isMarkedAsDeleted(Metric metric)
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
protected abstract boolean isMetricEnabled(String metricName)
-
register
public <T extends Metric> T register(String name, T metric) throws IllegalArgumentException
- Specified by:
register
in classMetricRegistry
- Throws:
IllegalArgumentException
-
register
public <T extends Metric> T register(Metadata metadata, T metric) throws IllegalArgumentException
- Specified by:
register
in classMetricRegistry
- Throws:
IllegalArgumentException
-
register
public <T extends Metric> T register(Metadata metadata, T metric, Tag... tags) throws IllegalArgumentException
- Specified by:
register
in classMetricRegistry
- Throws:
IllegalArgumentException
-
counter
public Counter counter(String name)
- Specified by:
counter
in classMetricRegistry
-
counter
public Counter counter(Metadata metadata)
- Specified by:
counter
in classMetricRegistry
-
counter
public Counter counter(String name, Tag... tags)
- Specified by:
counter
in classMetricRegistry
-
counter
public Counter counter(Metadata metadata, Tag... tags)
- Specified by:
counter
in classMetricRegistry
-
histogram
public Histogram histogram(String name)
- Specified by:
histogram
in classMetricRegistry
-
histogram
public Histogram histogram(Metadata metadata)
- Specified by:
histogram
in classMetricRegistry
-
histogram
public Histogram histogram(String name, Tag... tags)
- Specified by:
histogram
in classMetricRegistry
-
histogram
public Histogram histogram(Metadata metadata, Tag... tags)
- Specified by:
histogram
in classMetricRegistry
-
meter
public Meter meter(String name)
- Specified by:
meter
in classMetricRegistry
-
meter
public Meter meter(Metadata metadata)
- Specified by:
meter
in classMetricRegistry
-
meter
public Meter meter(String name, Tag... tags)
- Specified by:
meter
in classMetricRegistry
-
meter
public Meter meter(Metadata metadata, Tag... tags)
- Specified by:
meter
in classMetricRegistry
-
timer
public Timer timer(String name)
- Specified by:
timer
in classMetricRegistry
-
timer
public Timer timer(Metadata metadata)
- Specified by:
timer
in classMetricRegistry
-
timer
public Timer timer(String name, Tag... tags)
- Specified by:
timer
in classMetricRegistry
-
timer
public Timer timer(Metadata metadata, Tag... tags)
- Specified by:
timer
in classMetricRegistry
-
concurrentGauge
public ConcurrentGauge concurrentGauge(String name)
- Specified by:
concurrentGauge
in classMetricRegistry
-
concurrentGauge
public ConcurrentGauge concurrentGauge(Metadata metadata)
- Specified by:
concurrentGauge
in classMetricRegistry
-
concurrentGauge
public ConcurrentGauge concurrentGauge(String name, Tag... tags)
- Specified by:
concurrentGauge
in classMetricRegistry
-
concurrentGauge
public ConcurrentGauge concurrentGauge(Metadata metadata, Tag... tags)
- Specified by:
concurrentGauge
in classMetricRegistry
-
simpleTimer
public SimpleTimer simpleTimer(String name)
- Specified by:
simpleTimer
in classMetricRegistry
-
simpleTimer
public SimpleTimer simpleTimer(Metadata metadata)
- Specified by:
simpleTimer
in classMetricRegistry
-
simpleTimer
public SimpleTimer simpleTimer(String name, Tag... tags)
- Specified by:
simpleTimer
in classMetricRegistry
-
simpleTimer
public SimpleTimer simpleTimer(Metadata metadata, Tag... tags)
- Specified by:
simpleTimer
in classMetricRegistry
-
remove
public boolean remove(String name)
Removes a metric by name. Synchronized for atomic update of more than one internal map.- Specified by:
remove
in classMetricRegistry
- Parameters:
name
- Name of the metric.- Returns:
- Outcome of removal.
-
remove
public boolean remove(MetricID metricID)
Removes a metric by ID. Synchronized for atomic update of more than one internal map.- Specified by:
remove
in classMetricRegistry
- Parameters:
metricID
- ID of metric.- Returns:
- Outcome of removal.
-
removeMatching
public void removeMatching(MetricFilter filter)
- Specified by:
removeMatching
in classMetricRegistry
-
getNames
public SortedSet<String> getNames()
- Specified by:
getNames
in classMetricRegistry
-
getMetricIDs
public SortedSet<MetricID> getMetricIDs()
- Specified by:
getMetricIDs
in classMetricRegistry
-
getGauges
public SortedMap<MetricID,Gauge> getGauges()
- Specified by:
getGauges
in classMetricRegistry
-
getGauges
public SortedMap<MetricID,Gauge> getGauges(MetricFilter filter)
- Specified by:
getGauges
in classMetricRegistry
-
getCounters
public SortedMap<MetricID,Counter> getCounters()
- Specified by:
getCounters
in classMetricRegistry
-
getCounters
public SortedMap<MetricID,Counter> getCounters(MetricFilter filter)
- Specified by:
getCounters
in classMetricRegistry
-
getHistograms
public SortedMap<MetricID,Histogram> getHistograms()
- Specified by:
getHistograms
in classMetricRegistry
-
getHistograms
public SortedMap<MetricID,Histogram> getHistograms(MetricFilter filter)
- Specified by:
getHistograms
in classMetricRegistry
-
getMeters
public SortedMap<MetricID,Meter> getMeters()
- Specified by:
getMeters
in classMetricRegistry
-
getMeters
public SortedMap<MetricID,Meter> getMeters(MetricFilter filter)
- Specified by:
getMeters
in classMetricRegistry
-
getTimers
public SortedMap<MetricID,Timer> getTimers()
- Specified by:
getTimers
in classMetricRegistry
-
getTimers
public SortedMap<MetricID,Timer> getTimers(MetricFilter filter)
- Specified by:
getTimers
in classMetricRegistry
-
getConcurrentGauges
public SortedMap<MetricID,ConcurrentGauge> getConcurrentGauges()
- Specified by:
getConcurrentGauges
in classMetricRegistry
-
getConcurrentGauges
public SortedMap<MetricID,ConcurrentGauge> getConcurrentGauges(MetricFilter filter)
- Specified by:
getConcurrentGauges
in classMetricRegistry
-
getSimpleTimers
public SortedMap<MetricID,SimpleTimer> getSimpleTimers()
- Specified by:
getSimpleTimers
in classMetricRegistry
-
getSimpleTimers
public SortedMap<MetricID,SimpleTimer> getSimpleTimers(MetricFilter filter)
- Specified by:
getSimpleTimers
in classMetricRegistry
-
getMetadata
public Map<String,Metadata> getMetadata()
- Specified by:
getMetadata
in classMetricRegistry
-
getMetrics
public Map<MetricID,Metric> getMetrics()
- Specified by:
getMetrics
in classMetricRegistry
-
getMetric
public Optional<Metric> getMetric(String metricName)
Access a metric by name. Used by FT library.- Parameters:
metricName
- Metric name.- Returns:
- Optional metric.
-
type
public String type()
Returns type of this registry.- Returns:
- The type.
-
empty
public boolean empty()
Determines if registry is empty.- Returns:
- Outcome of test.
-
getOptionalMetricWithIDsEntry
public Optional<Map.Entry<? extends Metric,List<MetricID>>> getOptionalMetricWithIDsEntry(String metricName)
Get internal map entry given a metric name. Synchronized for atomic access of more than one internal map.- Parameters:
metricName
- The metric name.- Returns:
- Optional map entry..
-
getMetric
public M getMetric(MetricID metricID)
Lookup metric by its metric ID.- Parameters:
metricID
- the metric ID- Returns:
- the metric or
null
if not found
-
isStrictExemplars
protected boolean isStrictExemplars()
- Returns:
- whether exemplars are to be implemented strictly
-
stream
protected Stream<Map.Entry<MetricID,M>> stream()
Returns a stream ofMap.Entry
for this registry for enabled metrics.- Returns:
- Stream of
Map.Entry
-
toImpl
protected abstract <T extends Metric> M toImpl(Metadata metadata, T metric)
Creates a new instance of an implementation wrapper around the indicated metric.- Type Parameters:
T
- specific type ofMetric
provided and wrapped- Parameters:
metadata
-Metadata
for the metricmetric
- the existing metric to be wrapped by the impl- Returns:
- new wrapper implementation around the specified metric instance
-
prepareMetricFactories
protected abstract Map<MetricType,BiFunction<String,Metadata,M>> prepareMetricFactories()
-
registrySettings
protected RegistrySettings registrySettings()
-
getOptionalMetricEntry
protected Optional<Map.Entry<MetricID,M>> getOptionalMetricEntry(String metricName)
-
registryType
protected MetricRegistry.Type registryType()
-
deriveType
protected static MetricType deriveType(MetricType candidateType, Metric metric)
-
metricFactories
protected Map<MetricType,BiFunction<String,Metadata,M>> metricFactories()
-
prepareMetricToTypeMap
protected abstract Map<Class<? extends M>,MetricType> prepareMetricToTypeMap()
-
-