Copilot commented on code in PR #18685:
URL: https://github.com/apache/hudi/pull/18685#discussion_r3186173235


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/metrics/FlinkRLIBootstrapMetrics.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.flink.metrics.Gauge;
+import org.apache.flink.metrics.MetricGroup;
+
+/**
+ * Metrics for {@link org.apache.hudi.sink.bootstrap.RLIBootstrapOperator}.
+ *
+ * <p>Exposes gauges that are updated once after the bootstrap loading 
completes.
+ */
+public class FlinkRLIBootstrapMetrics extends HoodieFlinkMetrics {
+
+  public static final String NUM_FILE_SLICES_PROCESSED = 
"rliBootstrap.numFileSlicesProcessed";
+  public static final String NUM_INDEX_RECORDS_EMITTED = 
"rliBootstrap.numIndexRecordsEmitted";
+  public static final String BOOTSTRAP_COST_MS = 
"rliBootstrap.bootstrapCostMs";
+  public static final String BOOTSTRAP_RECORD_PER_MS = 
"rliBootstrap.bootstrapRecordPerMs";

Review Comment:
   This metric name advertises a per-millisecond rate, but `getThroughput()` 
multiplies by 1000 so the exported value is actually records per second. 
Because metric names are part of the external monitoring contract, publishing 
the wrong unit here will mislead dashboards and will be hard to correct later 
without a breaking rename.



##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/bootstrap/RLIBootstrapOperator.java:
##########
@@ -54,11 +55,22 @@ public class RLIBootstrapOperator
 
   private transient HoodieBackedTableMetadata metadataTable;
   private transient long loadedCnt;
+  private transient long numFileSlicesProcessed;
+  private transient long bootstrapCostMs;
+  private transient FlinkRLIBootstrapMetrics metrics;
 
   public RLIBootstrapOperator(Configuration conf) {
     super(conf);
   }
 
+  @Override
+  public void open() throws Exception {
+    super.open();
+    this.metrics = new 
FlinkRLIBootstrapMetrics(getRuntimeContext().getMetricGroup());
+    this.metrics.registerMetrics();
+    this.metrics.updateLoadResult(numFileSlicesProcessed, loadedCnt, 
bootstrapCostMs);

Review Comment:
   The new tests only exercise `FlinkRLIBootstrapMetrics` in isolation; they 
never run the `RLIBootstrapOperator` lifecycle that populates these values. 
Since the feature being added here is the operator wiring, please add an 
operator-level test that bootstraps data and asserts the runtime metrics are 
registered with the expected final counts.



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

Reply via email to