hudi-agent commented on code in PR #18685:
URL: https://github.com/apache/hudi/pull/18685#discussion_r3182885516


##########
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();

Review Comment:
   🤖 I think the gauges will always report 0 — `updateLoadResult` is only 
called once here in `open()` when 
`numFileSlicesProcessed`/`loadedCnt`/`bootstrapCostMs` are still their default 
zero values. After `preLoadRLIRecords()` finishes computing the actual values, 
there's no follow-up call to push them into the metrics object (whose gauges 
read from its own internal fields, not the operator's). Could you add a 
`metrics.updateLoadResult(numFileSlicesProcessed, loadedCnt, bootstrapCostMs)` 
call at the end of `preLoadRLIRecords()`?
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/metrics/TestFlinkRLIBootstrapMetrics.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.groups.UnregisteredMetricsGroup;
+import org.apache.hudi.configuration.OptionsInference;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;

Review Comment:
   🤖 This import (and other references below) point at `BOOTSTRAP_THROUGHPUT`, 
but the source class defines `BOOTSTRAP_RECORD_PER_MS = 
"rliBootstrap.bootstrapRecordPerMs"`. The test file as committed should not 
compile. Could you align the names? Related: the throughput calculation 
multiplies by 1000, so the value is records/second — the `RECORD_PER_MS` name 
in the source seems to disagree with the math (and with the test's `4000.0` 
expectation for 2000 records / 500 ms). Worth picking one unit and being 
consistent across the constant name, the metric label, and the computation.
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
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";
+
+  private long numFileSlicesProcessed;

Review Comment:
   🤖 nit: `BOOTSTRAP_RECORD_PER_MS` / `"rliBootstrap.bootstrapRecordPerMs"` is 
misleading — `getThroughput()` multiplies by 1000, so the value is actually 
records/second, not per-ms. Could you rename to `BOOTSTRAP_THROUGHPUT` / 
`"rliBootstrap.bootstrapThroughput"` to avoid a 1000× misinterpretation on 
dashboards? (The test already imports `BOOTSTRAP_THROUGHPUT`, which would be 
consistent with this rename.)
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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