Package org.apache.flink.runtime.metrics
Class MetricRegistryImpl
- java.lang.Object
-
- org.apache.flink.runtime.metrics.MetricRegistryImpl
-
- All Implemented Interfaces:
AutoCloseable,MetricRegistry,org.apache.flink.util.AutoCloseableAsync
public class MetricRegistryImpl extends Object implements MetricRegistry, org.apache.flink.util.AutoCloseableAsync
A MetricRegistry keeps track of all registeredMetrics. It serves as the connection betweenMetricGroupsandMetricReporters.
-
-
Constructor Summary
Constructors Constructor Description MetricRegistryImpl(MetricRegistryConfiguration config)MetricRegistryImpl(MetricRegistryConfiguration config, Collection<ReporterSetup> reporterConfigurations)MetricRegistryImpl(MetricRegistryConfiguration config, Collection<ReporterSetup> reporterConfigurations, Collection<TraceReporterSetup> traceReporterConfigurations, Collection<EventReporterSetup> eventReporterConfigurations)Creates a new MetricRegistry and starts the configured reporter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEvent(org.apache.flink.events.EventBuilder eventBuilder, AbstractMetricGroup<?> group)Add and log anEvent.voidaddSpan(org.apache.flink.traces.SpanBuilder spanBuilder, AbstractMetricGroup<?> group)Add and log aSpan.CompletableFuture<Void>closeAsync()Shuts down this registry and the associatedMetricReporter.chargetDelimiter()Returns the global delimiter.List<org.apache.flink.runtime.metrics.MetricRegistryImpl.ReporterAndSettings<org.apache.flink.events.reporter.EventReporter,org.apache.flink.events.EventBuilder>>getEventReporters()StringgetMetricQueryServiceGatewayRpcAddress()Returns the address under which theMetricQueryServiceis reachable.org.apache.flink.runtime.rpc.RpcServicegetMetricQueryServiceRpcService()Returns the rpc service that theMetricQueryServiceruns in.intgetNumberReporters()Returns the number of registered reporters.List<org.apache.flink.metrics.reporter.MetricReporter>getReporters()ScopeFormatsgetScopeFormats()Returns the scope formats.List<org.apache.flink.runtime.metrics.MetricRegistryImpl.ReporterAndSettings<org.apache.flink.traces.reporter.TraceReporter,org.apache.flink.traces.SpanBuilder>>getTraceReporters()booleanisShutdown()Returns whether this registry has been shutdown.voidregister(org.apache.flink.metrics.Metric metric, String metricName, AbstractMetricGroup<?> group)Registers a newMetricwith this registry.voidstartQueryService(org.apache.flink.runtime.rpc.RpcService rpcService, ResourceID resourceID)Initializes the MetricQueryService.voidunregister(org.apache.flink.metrics.Metric metric, String metricName, AbstractMetricGroup<?> group)Un-registers the givenMetricwith this registry.
-
-
-
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, Collection<EventReporterSetup> eventReporterConfigurations)
Creates a new MetricRegistry and starts the configured reporter.
-
-
Method Detail
-
startQueryService
public void startQueryService(org.apache.flink.runtime.rpc.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 org.apache.flink.runtime.rpc.RpcService getMetricQueryServiceRpcService()
Returns the rpc service that theMetricQueryServiceruns in.- Returns:
- rpc service of hte MetricQueryService
-
getMetricQueryServiceGatewayRpcAddress
@Nullable public String getMetricQueryServiceGatewayRpcAddress()
Returns the address under which theMetricQueryServiceis reachable.- Specified by:
getMetricQueryServiceGatewayRpcAddressin interfaceMetricRegistry- Returns:
- address of the metric query service
-
getDelimiter
public char getDelimiter()
Description copied from interface:MetricRegistryReturns the global delimiter.- Specified by:
getDelimiterin interfaceMetricRegistry- Returns:
- global delimiter
-
getNumberReporters
public int getNumberReporters()
Description copied from interface:MetricRegistryReturns the number of registered reporters.- Specified by:
getNumberReportersin interfaceMetricRegistry
-
getReporters
@VisibleForTesting public List<org.apache.flink.metrics.reporter.MetricReporter> getReporters()
-
getTraceReporters
@VisibleForTesting public List<org.apache.flink.runtime.metrics.MetricRegistryImpl.ReporterAndSettings<org.apache.flink.traces.reporter.TraceReporter,org.apache.flink.traces.SpanBuilder>> getTraceReporters()
-
getEventReporters
@VisibleForTesting public List<org.apache.flink.runtime.metrics.MetricRegistryImpl.ReporterAndSettings<org.apache.flink.events.reporter.EventReporter,org.apache.flink.events.EventBuilder>> getEventReporters()
-
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:
closeAsyncin interfaceorg.apache.flink.util.AutoCloseableAsync- Returns:
- Future which is completed once the
MetricRegistryImplis shut down.
-
getScopeFormats
public ScopeFormats getScopeFormats()
Description copied from interface:MetricRegistryReturns the scope formats.- Specified by:
getScopeFormatsin interfaceMetricRegistry- Returns:
- scope formats
-
addSpan
public void addSpan(org.apache.flink.traces.SpanBuilder spanBuilder, AbstractMetricGroup<?> group)Description copied from interface:MetricRegistryAdd and log aSpan.- Specified by:
addSpanin interfaceMetricRegistry
-
addEvent
public void addEvent(org.apache.flink.events.EventBuilder eventBuilder, AbstractMetricGroup<?> group)Description copied from interface:MetricRegistryAdd and log anEvent.- Specified by:
addEventin interfaceMetricRegistry
-
register
public void register(org.apache.flink.metrics.Metric metric, String metricName, AbstractMetricGroup<?> group)Description copied from interface:MetricRegistryRegisters a newMetricwith this registry.- Specified by:
registerin interfaceMetricRegistry- Parameters:
metric- the metric that was addedmetricName- the name of the metricgroup- the group that contains the metric
-
unregister
public void unregister(org.apache.flink.metrics.Metric metric, String metricName, AbstractMetricGroup<?> group)Description copied from interface:MetricRegistryUn-registers the givenMetricwith this registry.- Specified by:
unregisterin interfaceMetricRegistry- Parameters:
metric- the metric that should be removedmetricName- the name of the metricgroup- the group that contains the metric
-
-