nastra commented on code in PR #10459:
URL: https://github.com/apache/iceberg/pull/10459#discussion_r1631954976
##########
core/src/main/java/org/apache/iceberg/CatalogUtil.java:
##########
@@ -443,36 +443,42 @@ public static void configureHadoopConf(Object
maybeConfigurable, Object conf) {
public static MetricsReporter loadMetricsReporter(Map<String, String>
properties) {
String impl = properties.get(CatalogProperties.METRICS_REPORTER_IMPL);
if (impl == null) {
+ LOG.info(
+ "Custom metrics reporter is set, but the implementation is null.
Defaulting to LoggingMetricsReporter");
return LoggingMetricsReporter.instance();
}
LOG.info("Loading custom MetricsReporter implementation: {}", impl);
- DynConstructors.Ctor<MetricsReporter> ctor;
+
+ MetricsReporter reporter;
+
try {
- ctor =
- DynConstructors.builder(MetricsReporter.class)
- .loader(CatalogUtil.class.getClassLoader())
- .impl(impl)
- .buildChecked();
+ reporter = createMetricsReporter(impl,
CatalogUtil.class.getClassLoader());
} catch (NoSuchMethodException e) {
- throw new IllegalArgumentException(
- String.format("Cannot initialize MetricsReporter, missing no-arg
constructor: %s", impl),
- e);
+ try {
+ reporter = createMetricsReporter(impl,
Thread.currentThread().getContextClassLoader());
+ } catch (NoSuchMethodException e2) {
+ throw new IllegalArgumentException(
+ String.format("Cannot initialize MetricsReporter, missing no-arg
constructor: %s", impl), e2);
+ }
}
- MetricsReporter reporter;
+ reporter.initialize(properties);
+ return reporter;
+ }
+
+ private static MetricsReporter createMetricsReporter(String impl,
ClassLoader loader)
Review Comment:
```suggestion
private static MetricsReporter initMetricsReporter(String impl,
ClassLoader loader)
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]