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 protectedAbstractRegistry(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:
registerin classMetricRegistry- Throws:
IllegalArgumentException
-
register
public <T extends Metric> T register(Metadata metadata, T metric) throws IllegalArgumentException
- Specified by:
registerin classMetricRegistry- Throws:
IllegalArgumentException
-
register
public <T extends Metric> T register(Metadata metadata, T metric, Tag... tags) throws IllegalArgumentException
- Specified by:
registerin classMetricRegistry- Throws:
IllegalArgumentException
-
counter
public Counter counter(String name)
- Specified by:
counterin classMetricRegistry
-
counter
public Counter counter(Metadata metadata)
- Specified by:
counterin classMetricRegistry
-
counter
public Counter counter(String name, Tag... tags)
- Specified by:
counterin classMetricRegistry
-
counter
public Counter counter(Metadata metadata, Tag... tags)
- Specified by:
counterin classMetricRegistry
-
histogram
public Histogram histogram(String name)
- Specified by:
histogramin classMetricRegistry
-
histogram
public Histogram histogram(Metadata metadata)
- Specified by:
histogramin classMetricRegistry
-
histogram
public Histogram histogram(String name, Tag... tags)
- Specified by:
histogramin classMetricRegistry
-
histogram
public Histogram histogram(Metadata metadata, Tag... tags)
- Specified by:
histogramin classMetricRegistry
-
meter
public Meter meter(String name)
- Specified by:
meterin classMetricRegistry
-
meter
public Meter meter(Metadata metadata)
- Specified by:
meterin classMetricRegistry
-
meter
public Meter meter(String name, Tag... tags)
- Specified by:
meterin classMetricRegistry
-
meter
public Meter meter(Metadata metadata, Tag... tags)
- Specified by:
meterin classMetricRegistry
-
timer
public Timer timer(String name)
- Specified by:
timerin classMetricRegistry
-
timer
public Timer timer(Metadata metadata)
- Specified by:
timerin classMetricRegistry
-
timer
public Timer timer(String name, Tag... tags)
- Specified by:
timerin classMetricRegistry
-
timer
public Timer timer(Metadata metadata, Tag... tags)
- Specified by:
timerin classMetricRegistry
-
concurrentGauge
public ConcurrentGauge concurrentGauge(String name)
- Specified by:
concurrentGaugein classMetricRegistry
-
concurrentGauge
public ConcurrentGauge concurrentGauge(Metadata metadata)
- Specified by:
concurrentGaugein classMetricRegistry
-
concurrentGauge
public ConcurrentGauge concurrentGauge(String name, Tag... tags)
- Specified by:
concurrentGaugein classMetricRegistry
-
concurrentGauge
public ConcurrentGauge concurrentGauge(Metadata metadata, Tag... tags)
- Specified by:
concurrentGaugein classMetricRegistry
-
simpleTimer
public SimpleTimer simpleTimer(String name)
- Specified by:
simpleTimerin classMetricRegistry
-
simpleTimer
public SimpleTimer simpleTimer(Metadata metadata)
- Specified by:
simpleTimerin classMetricRegistry
-
simpleTimer
public SimpleTimer simpleTimer(String name, Tag... tags)
- Specified by:
simpleTimerin classMetricRegistry
-
simpleTimer
public SimpleTimer simpleTimer(Metadata metadata, Tag... tags)
- Specified by:
simpleTimerin classMetricRegistry
-
remove
public boolean remove(String name)
Removes a metric by name. Synchronized for atomic update of more than one internal map.- Specified by:
removein 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:
removein classMetricRegistry- Parameters:
metricID- ID of metric.- Returns:
- Outcome of removal.
-
removeMatching
public void removeMatching(MetricFilter filter)
- Specified by:
removeMatchingin classMetricRegistry
-
getNames
public SortedSet<String> getNames()
- Specified by:
getNamesin classMetricRegistry
-
getMetricIDs
public SortedSet<MetricID> getMetricIDs()
- Specified by:
getMetricIDsin classMetricRegistry
-
getGauges
public SortedMap<MetricID,Gauge> getGauges()
- Specified by:
getGaugesin classMetricRegistry
-
getGauges
public SortedMap<MetricID,Gauge> getGauges(MetricFilter filter)
- Specified by:
getGaugesin classMetricRegistry
-
getCounters
public SortedMap<MetricID,Counter> getCounters()
- Specified by:
getCountersin classMetricRegistry
-
getCounters
public SortedMap<MetricID,Counter> getCounters(MetricFilter filter)
- Specified by:
getCountersin classMetricRegistry
-
getHistograms
public SortedMap<MetricID,Histogram> getHistograms()
- Specified by:
getHistogramsin classMetricRegistry
-
getHistograms
public SortedMap<MetricID,Histogram> getHistograms(MetricFilter filter)
- Specified by:
getHistogramsin classMetricRegistry
-
getMeters
public SortedMap<MetricID,Meter> getMeters()
- Specified by:
getMetersin classMetricRegistry
-
getMeters
public SortedMap<MetricID,Meter> getMeters(MetricFilter filter)
- Specified by:
getMetersin classMetricRegistry
-
getTimers
public SortedMap<MetricID,Timer> getTimers()
- Specified by:
getTimersin classMetricRegistry
-
getTimers
public SortedMap<MetricID,Timer> getTimers(MetricFilter filter)
- Specified by:
getTimersin classMetricRegistry
-
getConcurrentGauges
public SortedMap<MetricID,ConcurrentGauge> getConcurrentGauges()
- Specified by:
getConcurrentGaugesin classMetricRegistry
-
getConcurrentGauges
public SortedMap<MetricID,ConcurrentGauge> getConcurrentGauges(MetricFilter filter)
- Specified by:
getConcurrentGaugesin classMetricRegistry
-
getSimpleTimers
public SortedMap<MetricID,SimpleTimer> getSimpleTimers()
- Specified by:
getSimpleTimersin classMetricRegistry
-
getSimpleTimers
public SortedMap<MetricID,SimpleTimer> getSimpleTimers(MetricFilter filter)
- Specified by:
getSimpleTimersin classMetricRegistry
-
getMetadata
public Map<String,Metadata> getMetadata()
- Specified by:
getMetadatain classMetricRegistry
-
getMetrics
public Map<MetricID,Metric> getMetrics()
- Specified by:
getMetricsin 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
nullif 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.Entryfor 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 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
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()
-
-