public class MetricsRegistryImpl extends Object implements MetricsRegistry
MetricsRegistry implementation.| Constructor and Description |
|---|
MetricsRegistryImpl(ILogger logger,
ProbeLevel minimumLevel)
Creates a MetricsRegistryImpl instance.
|
MetricsRegistryImpl(String name,
ILogger logger,
ProbeLevel minimumLevel)
Creates a MetricsRegistryImpl instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
collect(MetricsCollector collector)
Collects the content of the MetricsRegistry.
|
void |
deregisterDynamicMetricsProvider(DynamicMetricsProvider metricsProvider)
Deregisters the given dynamic metrics provider.
|
Set<String> |
getNames()
Gets a set of all current probe names.
|
ProbeLevel |
minimumLevel()
Returns the minimum ProbeLevel this MetricsRegistry is recording.
|
DoubleGauge |
newDoubleGauge(String name)
Creates a
DoubleGauge for a given metric name. |
com.hazelcast.internal.metrics.impl.LongGaugeImpl |
newLongGauge(String name)
Creates a
LongGauge for a given metric name. |
MetricTagger |
newMetricTagger()
Creates a new
MetricTagger. |
MetricTagger |
newMetricTagger(String namePrefix)
Creates a new
MetricTagger with the given metric name prefix. |
void |
provideMetrics(Object... providers)
For each object that implements
StaticMetricsProvider the
StaticMetricsProvider.provideStaticMetrics(MetricsRegistry) is called. |
void |
registerDynamicMetricsProvider(DynamicMetricsProvider metricsProvider)
Registers dynamic metrics sources that collect metrics in each metrics
collection cycle.
|
<S> void |
registerStaticMetrics(S source,
String namePrefix)
Scans the source object for any fields/methods that have been annotated
with
Probe annotation, and registers these fields/methods as
static probe instances. |
<S> void |
registerStaticProbe(S source,
String name,
ProbeLevel level,
DoubleProbeFunction<S> function)
Registers a probe.
|
<S> void |
registerStaticProbe(S source,
String name,
ProbeLevel level,
LongProbeFunction<S> function)
Registers a probe.
|
ScheduledFuture<?> |
scheduleAtFixedRate(Runnable publisher,
long period,
TimeUnit timeUnit,
ProbeLevel probeLevel)
Schedules a publisher to be executed at a fixed rate.
|
void |
shutdown() |
public MetricsRegistryImpl(ILogger logger, ProbeLevel minimumLevel)
logger - the ILogger usedminimumLevel - the minimum ProbeLevel. If a probe is registered with a ProbeLevel lower than the minimum ProbeLevel,
then the registration is skipped.NullPointerException - if logger or minimumLevel is nullpublic MetricsRegistryImpl(String name, ILogger logger, ProbeLevel minimumLevel)
name - Name of the registrylogger - the ILogger usedminimumLevel - the minimum ProbeLevel. If a probe is registered with a ProbeLevel lower than the minimum ProbeLevel,
then the registration is skipped.NullPointerException - if logger or minimumLevel is nullpublic ProbeLevel minimumLevel()
MetricsRegistryminimumLevel in interface MetricsRegistrypublic Set<String> getNames()
MetricsRegistrygetNames in interface MetricsRegistrypublic <S> void registerStaticMetrics(S source,
String namePrefix)
MetricsRegistryProbe annotation, and registers these fields/methods as
static probe instances.
If a probe is called 'queueSize' and the namePrefix is 'operations', then the name of the probe instance is 'operations.queueSize'.
If a probe with the same name already exists, then the probe is replaced.
If an object has no @Probe annotations, the call is ignored.
registerStaticMetrics in interface MetricsRegistrysource - the object to scan.namePrefix - the name prefix.public void registerDynamicMetricsProvider(DynamicMetricsProvider metricsProvider)
MetricsRegistryregisterDynamicMetricsProvider in interface MetricsRegistrymetricsProvider - The object that provides dynamic metricspublic void deregisterDynamicMetricsProvider(DynamicMetricsProvider metricsProvider)
MetricsRegistryderegisterDynamicMetricsProvider in interface MetricsRegistrymetricsProvider - The metrics provider to deregisterpublic <S> void registerStaticProbe(S source,
String name,
ProbeLevel level,
LongProbeFunction<S> function)
MetricsRegistryregisterStaticProbe in interface MetricsRegistryname - the name of the probe.level - the ProbeLevelfunction - the probepublic <S> void registerStaticProbe(S source,
String name,
ProbeLevel level,
DoubleProbeFunction<S> function)
MetricsRegistryregisterStaticProbe in interface MetricsRegistryname - the name of the probelevel - the ProbeLevelfunction - the probepublic com.hazelcast.internal.metrics.impl.LongGaugeImpl newLongGauge(String name)
MetricsRegistryLongGauge for a given metric name.
If no gauge exists for the name, it will be created but no probe is set.
The reason to do so is that you don't want to depend on the order of
registration. Perhaps you want to read out e.g. operations.count gauge,
but the OperationService has not started yet and the metric is not yet
available. Another cause is that perhaps a probe is not registered, but
the metric is created. For example when experimenting with a new
implementation, e.g. a new OperationService implementation, that doesn't
provide the operation.count probe.
Multiple calls with the same name return different Gauge instances; so
the Gauge instance is not cached. This is done to prevent memory leaks.newLongGauge in interface MetricsRegistryname - the name of the metric.public DoubleGauge newDoubleGauge(String name)
MetricsRegistryDoubleGauge for a given metric name.newDoubleGauge in interface MetricsRegistryname - name of the metricMetricsRegistry.newLongGauge(String)public void collect(MetricsCollector collector)
MetricsRegistrycollect in interface MetricsRegistrycollector - the collector that consumes the metrics collectedpublic void provideMetrics(Object... providers)
MetricsRegistryStaticMetricsProvider the
StaticMetricsProvider.provideStaticMetrics(MetricsRegistry) is called.provideMetrics in interface MetricsRegistryproviders - the array of objects to initialize.public ScheduledFuture<?> scheduleAtFixedRate(Runnable publisher, long period, TimeUnit timeUnit, ProbeLevel probeLevel)
MetricsRegistryscheduleAtFixedRate in interface MetricsRegistrypublisher - the published task that needs to be executedperiod - the time between executionstimeUnit - the time unit for periodprobeLevel - the ProbeLevel publisher it publishing on. This is needed to prevent scheduling
publishers if their probe level isn't sufficient.public void shutdown()
public MetricTagger newMetricTagger()
MetricsRegistryMetricTagger.newMetricTagger in interface MetricsRegistrypublic MetricTagger newMetricTagger(String namePrefix)
MetricsRegistryMetricTagger with the given metric name prefix.
This prefix will be appended to "metric" tag names for all metrics
created with the MetricTagger.newMetricTagger in interface MetricsRegistrynamePrefix - the name prefix.Copyright © 2019 Hazelcast, Inc.. All rights reserved.