PatrickRen commented on code in PR #54:
URL: 
https://github.com/apache/flink-connector-kafka/pull/54#discussion_r1351861716


##########
flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/source/reader/KafkaPartitionSplitReader.java:
##########
@@ -110,6 +110,13 @@ public RecordsWithSplitIds<ConsumerRecord<byte[], byte[]>> 
fetch() throws IOExce
             markEmptySplitsAsFinished(recordsBySplits);
             return recordsBySplits;
         }
+
+        // Track the record fetch lag
+        consumerRecords
+                .iterator()
+                .forEachRemaining(
+                        record -> 
kafkaSourceReaderMetrics.recordFetched(record.timestamp()));

Review Comment:
   Actually it is not accurate to use `ConsumerRecord#timestamp` directly as 
the event time. Users can specify their own `WatermarkStrategy` to extract 
event time from the payload of the record instead of using the timestamp on 
`ConsumerRecord`: 
https://github.com/apache/flink/blob/6b52a4107db7521a25f4f308891095c5ba33cca0/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java#L2025
   
   Fetch time is determined in split reader in fetcher manager thread, while 
event time is determined in SourceOperator in task's main thread, so there's a 
gap between, and that's why we didn't implement this metric in the first time. 



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