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



##########
File path: 
core/src/main/java/org/apache/iceberg/hadoop/HadoopMetricsContext.java
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.hadoop;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Map;
+import java.util.function.Consumer;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.iceberg.exceptions.ValidationException;
+import org.apache.iceberg.io.FileIOMetricsContext;
+
+/**
+ * FileIO Metrics implementation that delegates to Hadoop FileSystem
+ * statistics implementation using the provided scheme.
+ */
+public class HadoopMetricsContext implements FileIOMetricsContext {
+  public static final String SCHEME = "fileio.scheme";
+
+  private String scheme;
+  private transient FileSystem.Statistics statistics;
+
+  @Override
+  public void initialize(Map<String, String> properties) {
+    ValidationException.check(properties.containsKey(SCHEME),
+        "Scheme is required for Hadoop FileSystem metrics reporting");
+
+    // FileIO has no specific implementation class, but Hadoop will
+    // still track and report for the provided scheme.
+    this.scheme = properties.get(SCHEME);
+    this.statistics = FileSystem.getStatistics(scheme, null);
+  }
+
+  /**
+   * The Hadoop implementation delegates to the Hadoop delegates to the
+   * FileSystem.Statistics implementation and therefore does not require
+   * support for operations like unit() and count() as the counter
+   * values are not directly consumed.
+   *
+   * @param name name of the metric
+   * @param type numeric type of the counter value
+   * @param unit ignored

Review comment:
       Why include unit if it is ignored? Is this to supply information for 
other metrics collection libraries that require it?




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