stream2000 commented on code in PR #9515:
URL: https://github.com/apache/hudi/pull/9515#discussion_r1306838878


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/metrics/FlinkWriteMetrics.java:
##########
@@ -0,0 +1,130 @@
+/*
+ * 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.hudi.metrics;
+
+import org.apache.hudi.common.model.HoodieCommitMetadata;
+import org.apache.hudi.common.table.timeline.HoodieInstantTimeGenerator;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.collection.Pair;
+
+import org.apache.flink.metrics.MetricGroup;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.ParseException;
+
+/**
+ * Common flink write commit metadata metrics
+ */
+public class FlinkWriteMetrics extends HoodieFlinkMetrics {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(FlinkWriteMetrics.class);
+
+  protected final String actionType;
+
+  private long totalPartitionsWritten;
+  private long totalFilesInsert;
+  private long totalFilesUpdate;
+  private long totalRecordsWritten;
+  private long totalUpdateRecordsWritten;
+  private long totalInsertRecordsWritten;
+  private long totalBytesWritten;
+  private long totalScanTime;
+  private long totalCreateTime;
+  private long totalUpsertTime;
+  private long totalCompactedRecordsUpdated;
+  private long totalLogFilesCompacted;
+  private long totalLogFilesSize;
+  private long commitLatencyInMs;
+  private long commitFreshnessInMs;
+  private long commitEpochTimeInMs;
+  private long durationInMs;
+
+  public FlinkWriteMetrics(MetricGroup metricGroup, String actionType) {
+    super(metricGroup);
+    this.actionType = actionType;
+  }
+
+  @Override
+  public void registerMetrics() {
+    // register commit gauge
+    metricGroup.gauge(getMetricsName(actionType, "totalPartitionsWritten"), () 
-> totalPartitionsWritten);
+    metricGroup.gauge(getMetricsName(actionType, "totalFilesInsert"), () -> 
totalFilesInsert);
+    metricGroup.gauge(getMetricsName(actionType, "totalFilesUpdate"), () -> 
totalFilesUpdate);
+    metricGroup.gauge(getMetricsName(actionType, "totalRecordsWritten"), () -> 
totalRecordsWritten);
+    metricGroup.gauge(getMetricsName(actionType, "totalUpdateRecordsWritten"), 
() -> totalUpdateRecordsWritten);
+    metricGroup.gauge(getMetricsName(actionType, "totalInsertRecordsWritten"), 
() -> totalInsertRecordsWritten);
+    metricGroup.gauge(getMetricsName(actionType, "totalBytesWritten"), () -> 
totalBytesWritten);
+    metricGroup.gauge(getMetricsName(actionType, "totalScanTime"), () -> 
totalScanTime);
+    metricGroup.gauge(getMetricsName(actionType, "totalCreateTime"), () -> 
totalCreateTime);
+    metricGroup.gauge(getMetricsName(actionType, "totalUpsertTime"), () -> 
totalUpsertTime);
+    metricGroup.gauge(getMetricsName(actionType, 
"totalCompactedRecordsUpdated"), () -> totalCompactedRecordsUpdated);

Review Comment:
   > Do we need all these metrics?
   
   These metrics are common commit metrics and not all are useful in 
compaction. However, if we can gather metrics after the write coordinator 
commit in the future, these metrics will be useful.  We can keep them for 
future extensions or add them back when needed. 
   
   > How Spark handles these metrics? 
   
   Spark maintain a large metrics class and will gather these metrics for all 
write (clustering, compaction, common writes..). We can align with spark and 
keep these metrics. If we add some metrics to spark commit metrics, we can 
migrate them to flink easily and don't need do a large diff
   



-- 
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: commits-unsubscr...@hudi.apache.org

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

Reply via email to