Package org.apache.flink.runtime.metrics
Class MetricRegistryImpl
- java.lang.Object
-
- org.apache.flink.runtime.metrics.MetricRegistryImpl
-
- All Implemented Interfaces:
AutoCloseable
,MetricRegistry
,AutoCloseableAsync
public class MetricRegistryImpl extends Object implements MetricRegistry, AutoCloseableAsync
A MetricRegistry keeps track of all registeredMetrics
. It serves as the connection betweenMetricGroups
andMetricReporters
.
-
-
Constructor Summary
Constructors Constructor Description MetricRegistryImpl(MetricRegistryConfiguration config)
MetricRegistryImpl(MetricRegistryConfiguration config, Collection<ReporterSetup> reporterConfigurations)
MetricRegistryImpl(MetricRegistryConfiguration config, Collection<ReporterSetup> reporterConfigurations, Collection<TraceReporterSetup> traceReporterConfigurations)
Creates a new MetricRegistry and starts the configured reporter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSpan(SpanBuilder spanBuilder)
Add and log aSpan
.CompletableFuture<Void>
closeAsync()
Shuts down this registry and the associatedMetricReporter
.char
getDelimiter()
Returns the global delimiter.String
getMetricQueryServiceGatewayRpcAddress()
Returns the address under which theMetricQueryService
is reachable.RpcService
getMetricQueryServiceRpcService()
Returns the rpc service that theMetricQueryService
runs in.int
getNumberReporters()
Returns the number of registered reporters.List<MetricReporter>
getReporters()
ScopeFormats
getScopeFormats()
Returns the scope formats.boolean
isShutdown()
Returns whether this registry has been shutdown.void
register(Metric metric, String metricName, AbstractMetricGroup group)
Registers a newMetric
with this registry.void
startQueryService(RpcService rpcService, ResourceID resourceID)
Initializes the MetricQueryService.void
unregister(Metric metric, String metricName, AbstractMetricGroup group)
Un-registers the givenMetric
with this registry.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.util.AutoCloseableAsync
close
-
-
-
-
Constructor Detail
-
MetricRegistryImpl
public MetricRegistryImpl(MetricRegistryConfiguration config)
-
MetricRegistryImpl
public MetricRegistryImpl(MetricRegistryConfiguration config, Collection<ReporterSetup> reporterConfigurations)
-
MetricRegistryImpl
public MetricRegistryImpl(MetricRegistryConfiguration config, Collection<ReporterSetup> reporterConfigurations, Collection<TraceReporterSetup> traceReporterConfigurations)
Creates a new MetricRegistry and starts the configured reporter.
-
-
Method Detail
-
startQueryService
public void startQueryService(RpcService rpcService, ResourceID resourceID)
Initializes the MetricQueryService.- Parameters:
rpcService
- RpcService to create the MetricQueryService onresourceID
- resource ID used to disambiguate the actor name
-
getMetricQueryServiceRpcService
@Nullable public RpcService getMetricQueryServiceRpcService()
Returns the rpc service that theMetricQueryService
runs in.- Returns:
- rpc service of hte MetricQueryService
-
getMetricQueryServiceGatewayRpcAddress
@Nullable public String getMetricQueryServiceGatewayRpcAddress()
Returns the address under which theMetricQueryService
is reachable.- Specified by:
getMetricQueryServiceGatewayRpcAddress
in interfaceMetricRegistry
- Returns:
- address of the metric query service
-
getDelimiter
public char getDelimiter()
Description copied from interface:MetricRegistry
Returns the global delimiter.- Specified by:
getDelimiter
in interfaceMetricRegistry
- Returns:
- global delimiter
-
getNumberReporters
public int getNumberReporters()
Description copied from interface:MetricRegistry
Returns the number of registered reporters.- Specified by:
getNumberReporters
in interfaceMetricRegistry
-
getReporters
@VisibleForTesting public List<MetricReporter> getReporters()
-
isShutdown
public boolean isShutdown()
Returns whether this registry has been shutdown.- Returns:
- true, if this registry was shutdown, otherwise false
-
closeAsync
public CompletableFuture<Void> closeAsync()
Shuts down this registry and the associatedMetricReporter
.NOTE: This operation is asynchronous and returns a future which is completed once the shutdown operation has been completed.
- Specified by:
closeAsync
in interfaceAutoCloseableAsync
- Returns:
- Future which is completed once the
MetricRegistryImpl
is shut down.
-
getScopeFormats
public ScopeFormats getScopeFormats()
Description copied from interface:MetricRegistry
Returns the scope formats.- Specified by:
getScopeFormats
in interfaceMetricRegistry
- Returns:
- scope formats
-
addSpan
public void addSpan(SpanBuilder spanBuilder)
Description copied from interface:MetricRegistry
Add and log aSpan
.- Specified by:
addSpan
in interfaceMetricRegistry
-
register
public void register(Metric metric, String metricName, AbstractMetricGroup group)
Description copied from interface:MetricRegistry
Registers a newMetric
with this registry.- Specified by:
register
in interfaceMetricRegistry
- Parameters:
metric
- the metric that was addedmetricName
- the name of the metricgroup
- the group that contains the metric
-
unregister
public void unregister(Metric metric, String metricName, AbstractMetricGroup group)
Description copied from interface:MetricRegistry
Un-registers the givenMetric
with this registry.- Specified by:
unregister
in interfaceMetricRegistry
- Parameters:
metric
- the metric that should be removedmetricName
- the name of the metricgroup
- the group that contains the metric
-
-