rdblue commented on a change in pull request #4050:
URL: https://github.com/apache/iceberg/pull/4050#discussion_r806025322



##########
File path: aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIO.java
##########
@@ -104,8 +112,23 @@ private S3Client client() {
   @Override
   public void initialize(Map<String, String> properties) {
     this.awsProperties = new AwsProperties(properties);
-    this.awsClientFactory = AwsClientFactories.from(properties);
-    this.s3 = awsClientFactory::s3;
+
+    // Do not override s3 client if it was provided
+    if (s3 == null) {
+      this.s3 = AwsClientFactories.from(properties)::s3;
+    }
+
+    // Report Hadoop metrics if Hadoop is available
+    try {
+      Class<? extends MetricsContext> clazz = 
DynClasses.builder().impl(DEFAULT_METRICS_IMPL).buildChecked();
+
+      this.metrics = clazz.getDeclaredConstructor().newInstance();
+      metrics.initialize(ImmutableMap.of("fileio.scheme", "s3"));

Review comment:
       Do you think that other metrics objects will also be loaded dynamically? 
If not, I'd probably just pass `"s3"` to the constructor:
   
   ```java
       this.metrics = DynConstructors.builder()
           .hiddenImpl("org.apache.iceberg.hadoop.HadoopMetricsContext", 
String.class)
           .buildChecked()
           .newInstance("s3");
   ```




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