This is not intended to be the interface which developers use to work with Helidon metrics. Instead use
- the
Metrics
interface and its static convenience methods, - the static methods on the various meter interfaces in the API (such as
Timer
, or Metrics.globalRegistry()
and use the returnedMeterRegistry
directly
An implementation of this interface provides instance methods for each
of the static methods on the Helidon metrics API interfaces. The prefix of each method
here identifies the interface that bears the corresponding static method. For example,
timerStart(io.helidon.metrics.api.MeterRegistry)
corresponds to the static
Timer.start(io.helidon.metrics.api.MeterRegistry)
method.
Also, various static methods create new instances or return previously-created ones.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the systemClock
from the underlying metrics implementation.void
close()
Closes this metrics factory.static void
closeAll()
Closes allMetricsFactory
instances.counterBuilder
(String name) Creates a builder for aCounter
.createMeterRegistry
(Clock clock, MetricsConfig metricsConfig) createMeterRegistry
(Clock clock, MetricsConfig metricsConfig, Consumer<Meter> onAddListener, Consumer<Meter> onRemoveListener) Creates a newMeterRegistry
using the providedClock
andMetricsConfig
and enrolling the specified listners with the new meter registry.createMeterRegistry
(MetricsConfig metricsConfig) Creates a newMeterRegistry
using the provided metrics config.createMeterRegistry
(MetricsConfig metricsConfig, Consumer<Meter> onAddListener, Consumer<Meter> onRemoveListener) Creates a newMeterRegistry
using the provided metrics config and enrolling the specified listeners with the returned meter registry.Creates a builder for aDistributionStatisticsConfig
.distributionSummaryBuilder
(String name, DistributionStatisticsConfig.Builder configBuilder) Creates a builder for aDistributionSummary
.<T> FunctionalCounter.Builder
<T> functionalCounterBuilder
(String name, T stateObject, Function<T, Long> fn) Creates a builder for a functionalCounter
, essentially a counter-style wrapper around an external object.<N extends Number>
Gauge.Builder<N> gaugeBuilder
(String name, Supplier<N> supplier) <T> Gauge.Builder
<Double> gaugeBuilder
(String name, T stateObject, ToDoubleFunction<T> fn) Creates a builder for a state-basedGauge
.static MetricsFactory
Returns the most-recently created implementation or, if none, a new one from a highest-weight provider available at runtime and using the "metrics" section from theGlobalConfig
.static MetricsFactory
getInstance
(Config metricsConfigNode) Returns a new metrics factory instance from a highest-weight provider using the providedConfig
to set up the metrics factory and saving the resulting metrics factory as the current one, returned bygetInstance()
}.Returns the globalMeterRegistry
for this metrics factory.globalRegistry
(MetricsConfig metricsConfig) Creates a new global registry according to the configuration and returns it.globalRegistry
(Consumer<Meter> onAddListener, Consumer<Meter> onRemoveListener, boolean backfill) Returns the globalMeterRegistry
enrolling the specified listeners to the meter registry.histogramSnapshotEmpty
(long count, double total, double max) Returns an empty histogram snapshot with the specified aggregate values.<B extends MeterRegistry.Builder<B,
M>, M extends MeterRegistry>
BReturns a builder for creating a newMeterRegistry
.Returns theMetricsConfig
instance used to initialize the metrics factory.default Meter
noOpMeter
(Meter.Builder<?, ?> builder) Returns a no-opMeter
of the type implied by the builder's runtime type, initialized with the builder's name and other required parameters.Creates aTag
from the specified key and value.timerBuilder
(String name) Creates a builder for aTimer
.Returns aTimer.Sample
for measuring a duration using the system defaultClock
.timerStart
(Clock clock) Returns aTimer.Sample
for measuring a duration using the specifiedClock
.timerStart
(MeterRegistry registry) Returns aTimer.Sample
for measuring a duration, using the clock associated with the specifiedMeterRegistry
.
-
Method Details
-
getInstance
Returns the most-recently created implementation or, if none, a new one from a highest-weight provider available at runtime and using the "metrics" section from theGlobalConfig
.- Returns:
- current or new metrics factory
-
getInstance
Returns a new metrics factory instance from a highest-weight provider using the providedConfig
to set up the metrics factory and saving the resulting metrics factory as the current one, returned bygetInstance()
}.- Parameters:
metricsConfigNode
- metrics config node- Returns:
- new instance configured as directed
-
closeAll
static void closeAll()Closes allMetricsFactory
instances.Applications do not normally need to invoke this method.
-
close
void close()Closes this metrics factory.Applications do not normally need to invoke this method.
-
globalRegistry
MeterRegistry globalRegistry()Returns the globalMeterRegistry
for this metrics factory.The metric factory creates its global registry on-demand using
getInstance()
.createMeterRegistry(MetricsConfig)
with aMetricsConfig
instance derived from the rootConfig
most recently passed togetInstance(io.helidon.common.config.Config)
, or if none then the config fromGlobalConfig
.- Returns:
- the global meter registry
-
globalRegistry
Creates a new global registry according to the configuration and returns it.- Parameters:
metricsConfig
- configuration to control the meter registry- Returns:
- meter registry
-
globalRegistry
MeterRegistry globalRegistry(Consumer<Meter> onAddListener, Consumer<Meter> onRemoveListener, boolean backfill) Returns the globalMeterRegistry
enrolling the specified listeners to the meter registry.- Parameters:
onAddListener
- invoked whenever a new meter is added to the returned meter registryonRemoveListener
- invoked whenever a meter is removed from the returned meter registrybackfill
- whether the meter registry should invoke the on-add listener for meters already present in an existing global registry- Returns:
- on-demand global registry with the indicated listeners added
-
metricsConfig
MetricsConfig metricsConfig()Returns theMetricsConfig
instance used to initialize the metrics factory.- Returns:
- metrics config used to create the metrics factory
-
meterRegistryBuilder
Returns a builder for creating a newMeterRegistry
.- Type Parameters:
B
- specific type of the builderM
- specific type of the registry- Returns:
- the new builder
-
createMeterRegistry
Creates a newMeterRegistry
using the provided metrics config.- Parameters:
metricsConfig
- metrics configuration which influences the new registry- Returns:
- new meter registry
-
createMeterRegistry
MeterRegistry createMeterRegistry(MetricsConfig metricsConfig, Consumer<Meter> onAddListener, Consumer<Meter> onRemoveListener) Creates a newMeterRegistry
using the provided metrics config and enrolling the specified listeners with the returned meter registry.- Parameters:
metricsConfig
- metrics configuration which influences the new registryonAddListener
- invoked whenever a new meter is added to the meter registryonRemoveListener
- invoked whenever a new meter is removed from the meter registry- Returns:
- new meter registry with the listeners enrolled
-
createMeterRegistry
- Parameters:
clock
- default clock to associate with the meter registrymetricsConfig
- metrics configuration which influences the new registry- Returns:
- new meter registry
-
createMeterRegistry
MeterRegistry createMeterRegistry(Clock clock, MetricsConfig metricsConfig, Consumer<Meter> onAddListener, Consumer<Meter> onRemoveListener) Creates a newMeterRegistry
using the providedClock
andMetricsConfig
and enrolling the specified listners with the new meter registry.- Parameters:
clock
- clock to associate with the meter registrymetricsConfig
- metrics config which influences the new registryonAddListener
- invoked whenever a new meter is added to the meter registryonRemoveListener
- invoked whenever a new meter is removed from the meter registry- Returns:
- new meter registry
-
clockSystem
Clock clockSystem()Returns the systemClock
from the underlying metrics implementation.- Returns:
- the system clock
-
counterBuilder
Creates a builder for aCounter
.- Parameters:
name
- name of the counter- Returns:
- counter builder
-
functionalCounterBuilder
<T> FunctionalCounter.Builder<T> functionalCounterBuilder(String name, T stateObject, Function<T, Long> fn) Creates a builder for a functionalCounter
, essentially a counter-style wrapper around an external object.- Type Parameters:
T
- type of the state object- Parameters:
name
- name of the counterstateObject
- object which provides the counter valuefn
- function which, when applied to the state object, yields the counter value- Returns:
- counter builder
-
distributionStatisticsConfigBuilder
DistributionStatisticsConfig.Builder distributionStatisticsConfigBuilder()Creates a builder for aDistributionStatisticsConfig
.- Returns:
- statistics config builder
-
distributionSummaryBuilder
DistributionSummary.Builder distributionSummaryBuilder(String name, DistributionStatisticsConfig.Builder configBuilder) Creates a builder for aDistributionSummary
.- Parameters:
name
- name of the summaryconfigBuilder
- distribution stats config the summary should use- Returns:
- summary builder
-
gaugeBuilder
Creates a builder for a state-basedGauge
.- Type Parameters:
T
- type of the state object- Parameters:
name
- name of the gaugestateObject
- object which maintains the value to be exposed via the gaugefn
- function which, when applied to the state object, returns the gauge value- Returns:
- gauge builder
-
gaugeBuilder
- Type Parameters:
N
- subtype ofNumber
which the supplier providers- Parameters:
name
- gauge namesupplier
- supplier for an instance of the specified subtype ofNumber
- Returns:
- new builder
-
timerBuilder
Creates a builder for aTimer
.- Parameters:
name
- name of the timer- Returns:
- timer builder
-
timerStart
Timer.Sample timerStart()Returns aTimer.Sample
for measuring a duration using the system defaultClock
.- Returns:
- new sample
-
timerStart
Returns aTimer.Sample
for measuring a duration, using the clock associated with the specifiedMeterRegistry
.- Parameters:
registry
- the meter registry whoseClock
is to be used- Returns:
- new sample with the start time recorded
-
timerStart
Returns aTimer.Sample
for measuring a duration using the specifiedClock
.- Parameters:
clock
- the clock to use for measuring the duration- Returns:
- new sample
-
tagCreate
Creates aTag
from the specified key and value.- Parameters:
key
- tag keyvalue
- tag value- Returns:
- new
Tag
instance
-
histogramSnapshotEmpty
Returns an empty histogram snapshot with the specified aggregate values.- Parameters:
count
- counttotal
- totalmax
- max value- Returns:
- histogram snapshot
-
noOpMeter
Returns a no-opMeter
of the type implied by the builder's runtime type, initialized with the builder's name and other required parameters.- Parameters:
builder
- original builder- Returns:
- corresponding no-op meter
-