gong commented on code in PR #7443:
URL: https://github.com/apache/inlong/pull/7443#discussion_r1118551575


##########
inlong-sort/sort-connectors/cdc-base/src/main/java/org/apache/inlong/sort/cdc/base/source/metrics/SourceReaderMetrics.java:
##########
@@ -0,0 +1,155 @@
+/*
+ * 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.inlong.sort.cdc.base.source.metrics;
+
+import static org.apache.inlong.sort.base.Constants.NUM_BYTES_IN;
+import static org.apache.inlong.sort.base.Constants.NUM_RECORDS_IN;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.flink.metrics.Gauge;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.inlong.sort.base.Constants;
+import org.apache.inlong.sort.base.enums.ReadPhase;
+import org.apache.inlong.sort.base.metric.MetricOption;
+import org.apache.inlong.sort.base.metric.MetricState;
+import org.apache.inlong.sort.base.metric.sub.SourceTableMetricData;
+import 
org.apache.inlong.sort.cdc.base.source.meta.split.MetricSplit.TableMetric;
+
+/**
+ * A collection class for handling metrics in {@link SourceReaderMetrics}.
+ */
+public class SourceReaderMetrics {
+
+    private final MetricGroup metricGroup;
+
+    /**
+     * The last record processing time, which is updated after {@link 
SourceReaderMetrics} fetches a
+     * batch of data. It's mainly used to report metrics sourceIdleTime for 
sourceIdleTime =
+     * System.currentTimeMillis() - processTime.
+     */
+    private volatile long processTime = 0L;
+
+    /**
+     * currentFetchEventTimeLag = FetchTime - messageTimestamp, where the 
FetchTime is the time the
+     * record fetched into the source operator.
+     */
+    private volatile long fetchDelay = 0L;
+
+    /**
+     * emitDelay = EmitTime - messageTimestamp, where the EmitTime is the time 
the record leaves the
+     * source operator.
+     */
+    private volatile long emitDelay = 0L;
+
+    private SourceTableMetricData sourceTableMetricData;
+
+    public SourceReaderMetrics(MetricGroup metricGroup) {
+        this.metricGroup = metricGroup;
+    }
+
+    public void registerMetrics(MetricOption metricOption) {
+        if (metricOption != null) {
+            sourceTableMetricData = new SourceTableMetricData(metricOption, 
metricGroup,
+                    Arrays.asList(Constants.DATABASE_NAME, 
Constants.COLLECTION_NAME));

Review Comment:
   `Arrays.asList(Constants.DATABASE_NAME, Constants.COLLECTION_NAME)` not only 
for mongo. You need add a list prams pass labels



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