tillrohrmann commented on a change in pull request #8373:
[FLINK-11922][metrics] Support MetricReporter factories
URL: https://github.com/apache/flink/pull/8373#discussion_r282396893
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/ReporterSetup.java
##########
@@ -131,46 +137,119 @@ private static ReporterSetup createReporterSetup(String
reporterName, MetricConf
}
}
- List<Tuple2<String, Configuration>> reporterConfigurations;
-
if (namedReporters.isEmpty()) {
- reporterConfigurations = Collections.emptyList();
- } else {
- reporterConfigurations = new
ArrayList<>(namedReporters.size());
+ return Collections.emptyList();
+ }
- for (String namedReporter: namedReporters) {
- DelegatingConfiguration delegatingConfiguration
= new DelegatingConfiguration(
- configuration,
- ConfigConstants.METRICS_REPORTER_PREFIX
+ namedReporter + '.');
+ List<Tuple2<String, Configuration>> reporterConfigurations =
new ArrayList<>(namedReporters.size());
-
reporterConfigurations.add(Tuple2.of(namedReporter, (Configuration)
delegatingConfiguration));
- }
+ for (String namedReporter: namedReporters) {
+ DelegatingConfiguration delegatingConfiguration = new
DelegatingConfiguration(
+ configuration,
+ ConfigConstants.METRICS_REPORTER_PREFIX +
namedReporter + '.');
+
+ reporterConfigurations.add(Tuple2.of(namedReporter,
(Configuration) delegatingConfiguration));
}
+ final Collection<MetricReporterFactory> reporterFactories =
loadReporterFactories();
List<ReporterSetup> reporterArguments = new
ArrayList<>(reporterConfigurations.size());
for (Tuple2<String, Configuration> reporterConfiguration:
reporterConfigurations) {
String reporterName = reporterConfiguration.f0;
Configuration reporterConfig = reporterConfiguration.f1;
try {
- final String reporterClassName =
reporterConfig.getString(ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, null);
- if (reporterClassName == null) {
- LOG.error("No reporter class set for
reporter " + reporterName + ". Metrics might not be exposed/reported.");
- continue;
- }
-
- Class<?> reporterClass =
Class.forName(reporterClassName);
- MetricReporter reporter = (MetricReporter)
reporterClass.newInstance();
+ Optional<MetricReporter> metricReporterOptional
= loadReporter(reporterName, reporterConfig, reporterFactories);
+ if (metricReporterOptional.isPresent()) {
Review comment:
`metricReporterOptional.ifPresent()` is a bit more succinct.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services