jackye1995 commented on a change in pull request #4254:
URL: https://github.com/apache/iceberg/pull/4254#discussion_r818233428



##########
File path: aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIO.java
##########
@@ -117,15 +120,18 @@ public void initialize(Map<String, String> properties) {
     }
 
     // Report Hadoop metrics if Hadoop is available
-    try {
-      DynConstructors.Ctor<MetricsContext> ctor =
-          
DynConstructors.builder(MetricsContext.class).hiddenImpl(DEFAULT_METRICS_IMPL, 
String.class).buildChecked();
-      this.metrics = ctor.newInstance("s3");
-
-      metrics.initialize(properties);
-    } catch (NoSuchMethodException | ClassCastException e) {
-      LOG.warn("Unable to load metrics class: '{}', falling back to null 
metrics", DEFAULT_METRICS_IMPL, e);
+    String metricsImpl = properties.getOrDefault(
+            CatalogProperties.IO_METRICS_IMPL, 
CatalogProperties.IO_METRICS_IMPL_DEFAULT);
+
+    ImmutableMap<String, String> metricContextProperties = 
ImmutableMap.copyOf(properties);
+    if (!properties.containsKey(CatalogProperties.IO_METRICS_SCHEME)) {
+      metricContextProperties = ImmutableMap.<String, String>builder()
+              .putAll(properties)
+              .put(CatalogProperties.IO_METRICS_SCHEME, IO_METRICS_SCHEME_S3)
+              .build();
     }
+
+    this.metrics = CatalogUtil.loadFileIOMetricsContext(metricsImpl, 
metricContextProperties, null);

Review comment:
       nit: add an inline comment for null input:
   
   ```java
   CatalogUtil.loadFileIOMetricsContext(metricsImpl, metricContextProperties, 
null /* no Hadoop config */);
   ```




-- 
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]

Reply via email to