rionmonster commented on code in PR #27598:
URL: https://github.com/apache/flink/pull/27598#discussion_r2806264438


##########
flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/utils/InvocationTrackingInternalSinkCommitterMetricGroup.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.flink.runtime.metrics.groups.utils;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.metrics.Counter;
+import org.apache.flink.metrics.Gauge;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.metrics.groups.OperatorIOMetricGroup;
+import org.apache.flink.metrics.groups.OperatorMetricGroup;
+import org.apache.flink.metrics.groups.SinkCommitterMetricGroup;
+import org.apache.flink.runtime.metrics.MetricNames;
+import org.apache.flink.runtime.metrics.groups.ProxyMetricGroup;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Internal
+public class InvocationTrackingInternalSinkCommitterMetricGroup

Review Comment:
   While I appreciate the detail and completeness of this custom metric group, 
I think in this case we could probably get away with a much smaller static 
testing class directly within the `CommittableCollectorTest.java` itself which 
is a pretty common pattern and would greatly reduce the surface area of the 
changes:
   
   ```
   #CommittableCollectorTest.java
   
   private static final TestCommitterMetricGroup METRIC_GROUP = new 
TestCommitterMetricGroup();
   
   // Omitted for brevity
   
   private static class TestCommitterMetricGroup extends 
InternalSinkCommitterMetricGroup {
   
       private final AtomicInteger gaugeCallCount = new AtomicInteger(0);
   
       TestCommitterMetricGroup() {
           super(new UnregisteredMetricsGroup(), 
UnregisteredMetricsGroup.createOperatorIOMetricGroup());
       }
   
       @Override
       public void setCurrentPendingCommittablesGauge(Gauge<Integer> gauge) {
           gaugeCallCount.incrementAndGet();
           super.setCurrentPendingCommittablesGauge(gauge);
       }
   
       int getGaugeCallCount() {
           return gaugeCallCount.get();
       }
   
       void resetGaugeCallCount() {
           gaugeCallCount.set(0);
       }
   }
   ```



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