You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "nastra (via GitHub)" <gi...@apache.org> on 2023/03/22 14:06:49 UTC

[GitHub] [iceberg] nastra commented on a diff in pull request #6919: Add HasScan metrics interface

nastra commented on code in PR #6919:
URL: https://github.com/apache/iceberg/pull/6919#discussion_r1144860026


##########
core/src/main/java/org/apache/iceberg/TableScanContext.java:
##########
@@ -351,14 +352,15 @@ TableScanContext planWith(ExecutorService executor) {
         toSnapshotId,
         executor,
         fromSnapshotInclusive,
-        metricsReporter);
+        metricsReporters);
   }
 
-  MetricsReporter metricsReporter() {
-    return metricsReporter;
+  Collection<MetricsReporter> metricsReporter() {
+    return metricsReporters;
   }
 
   TableScanContext reportWith(MetricsReporter reporter) {
+    metricsReporter().add(reporter);

Review Comment:
   I agree that this seems like the better approach



##########
spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/SparkMetricsReporter.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.spark;
+
+import org.apache.iceberg.metrics.MetricsReport;
+import org.apache.iceberg.metrics.MetricsReporter;
+
+/** Spark specific metric reporter. */
+public class SparkMetricsReporter implements MetricsReporter {
+
+  private MetricsReport metricsReport;
+
+  @Override
+  public void report(MetricsReport report) {
+    this.metricsReport = report;
+  }
+
+  MetricsReport getMetricsReport() {

Review Comment:
   I believe @karuppayya meant to report from here directly to Spark metrics. @karuppayya were you planning to add that functionality as part of this PR?



##########
.palantir/revapi.yml:
##########
@@ -66,6 +66,9 @@ acceptedBreaks:
       old: "method void org.apache.iceberg.io.DataWriter<T>::add(T)"
       justification: "Removing deprecated method"
   "1.1.0":
+    org.apache.iceberg:iceberg-api:
+    - code: "java.method.addedToInterface"
+      justification: "Add metricsreporter to Scan"

Review Comment:
   +1 to that



##########
api/src/main/java/org/apache/iceberg/Scan.java:
##########
@@ -171,4 +172,7 @@ default ThisT select(String... columns) {
 
   /** Returns the split open file cost for this scan. */
   long splitOpenFileCost();
+
+  /** Create a new scan that will report the scan metrics to the {@code reporter} */
+  ThisT withMetricsReporter(Collection<MetricsReporter> reporter);

Review Comment:
   +1 to that suggestion



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org