1996fanrui commented on code in PR #743:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/743#discussion_r1440197015


##########
flink-autoscaler/src/main/java/org/apache/flink/autoscaler/metrics/ScalingMetrics.java:
##########
@@ -216,15 +216,20 @@ private static double getNumRecordsInPerSecond(
             Map<FlinkMetric, AggregatedMetric> flinkMetrics,
             JobVertexID jobVertexID,
             boolean isSource) {
+        // If the vertex is not the source, use NUM_RECORDS_IN_PER_SEC metric
         var numRecordsInPerSecond = 
flinkMetrics.get(FlinkMetric.NUM_RECORDS_IN_PER_SEC);
+        // If the vertex is the source, use SOURCE_TASK_NUM_RECORDS_IN_PER_SEC 
metric
         if (isSource && (numRecordsInPerSecond == null || 
numRecordsInPerSecond.getSum() == 0)) {
             numRecordsInPerSecond =
                     
flinkMetrics.get(FlinkMetric.SOURCE_TASK_NUM_RECORDS_IN_PER_SEC);
         }
+        // If the vertex is the source and SOURCE_TASK_NUM_RECORDS_IN_PER_SEC 
metric not available
+        // then use SOURCE_TASK_NUM_RECORDS_OUT_PER_SEC metric
         if (isSource && (numRecordsInPerSecond == null || 
numRecordsInPerSecond.getSum() == 0)) {
             numRecordsInPerSecond =
                     
flinkMetrics.get(FlinkMetric.SOURCE_TASK_NUM_RECORDS_OUT_PER_SEC);
         }

Review Comment:
   ```suggestion
           // Generate numRecordsInPerSecond from 3 metrics:
           // 1. If the vertex is not the source, use NUM_RECORDS_IN_PER_SEC 
metric
           var numRecordsInPerSecond = 
flinkMetrics.get(FlinkMetric.NUM_RECORDS_IN_PER_SEC);
           // 2. If the vertex is the source, use 
SOURCE_TASK_NUM_RECORDS_IN_PER_SEC metric first.
           if (isSource && (numRecordsInPerSecond == null || 
numRecordsInPerSecond.getSum() == 0)) {
               numRecordsInPerSecond =
                       
flinkMetrics.get(FlinkMetric.SOURCE_TASK_NUM_RECORDS_IN_PER_SEC);
           }
           // 3. If the vertex is the source and 
SOURCE_TASK_NUM_RECORDS_IN_PER_SEC metric not available
           // then use SOURCE_TASK_NUM_RECORDS_OUT_PER_SEC metric
           if (isSource && (numRecordsInPerSecond == null || 
numRecordsInPerSecond.getSum() == 0)) {
               numRecordsInPerSecond =
                       
flinkMetrics.get(FlinkMetric.SOURCE_TASK_NUM_RECORDS_OUT_PER_SEC);
           }
   ```
   
   How about adding the `Generate numRecordsInPerSecond from 3 metrics:` and 
the `1. 2. 3.`?



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