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


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/metrics/FlinkIndexBackendMetrics.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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 com.codahale.metrics.SlidingWindowReservoir;
+import org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper;
+import org.apache.flink.metrics.Histogram;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.hudi.common.util.VisibleForTesting;
+
+/**
+ * Metrics for the {@link 
org.apache.hudi.sink.partitioner.index.GlobalRecordLevelIndexBackend}.
+ * Tracks cache hit/miss counts and the latency of local (cache) vs. remote 
(metadata table) lookups.
+ */
+public class FlinkIndexBackendMetrics extends HoodieFlinkMetrics {
+  private static final int HISTOGRAM_WINDOW_SIZE = 100;
+  private static final String LOCAL_INDEX_LOOKUP_KEY = "local_index_lookup";
+  private static final String REMOTE_INDEX_LOOKUP_KEY = "remote_index_lookup";
+
+  /** Latency of the local (cache) phase of each index lookup, in 
milliseconds. */
+  private final Histogram localIndexLookupLatency;
+
+  /** Latency of the remote (metadata table) phase of each index lookup, in 
milliseconds. */
+  private final Histogram remoteIndexLookupLatency;
+
+  /** Number of keys resolved from the local cache per lookup. */
+  private final Histogram localLookupKeysNum;
+
+  /** Number of keys that missed the local cache and were fetched remotely per 
lookup. */

Review Comment:
   🤖 nit: the fields/registered metric names use `Num` (e.g. 
`localLookupKeysNum`, `"localLookupKeysNum"`) but the public methods use 
`Count` (e.g. `updateLocalLookupKeysCount`). Could you pick one suffix and use 
it consistently? Either rename the fields/strings to 
`localLookupKeysCount`/`remoteLookupKeysCount`, or rename the methods to 
`updateLocalLookupKeysNum`.
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/MinibatchBucketAssignFunction.java:
##########
@@ -199,6 +207,11 @@ public void setCorrespondent(Correspondent correspondent) {
     this.delegateFunction.setCorrespondent(correspondent);
   }
 
+  @VisibleForTesting

Review Comment:
   🤖 nit: `getDelegateMetrics()` leaks the internal delegation structure — if 
the implementation ever stops delegating, the name becomes misleading. Since 
`BucketAssignFunction` already exposes `getMetrics()`, could you use the same 
name here for consistency?
   
   <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