scwhittle commented on code in PR #32402:
URL: https://github.com/apache/beam/pull/32402#discussion_r1764671383


##########
sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaUnboundedReader.java:
##########
@@ -568,7 +577,22 @@ private void consumerPollLoop() {
       while (!closed.get()) {
         try {
           if (records.isEmpty()) {
+            // Each source has a single unique topic.
+            List<TopicPartition> topicPartitions = 
source.getSpec().getTopicPartitions();
+            Preconditions.checkStateNotNull(topicPartitions);
+            String topicName = "null"; // value will be overridden
+            for (TopicPartition topicPartition : topicPartitions) {
+              topicName = topicPartition.topic();
+              break;
+            }
+
+            java.time.Instant operationStartTime = java.time.Instant.now();

Review Comment:
   do we need the start/end or just elapsed? If so I think 
https://guava.dev/releases/19.0/api/docs/com/google/common/base/Stopwatch.html 
is preferred as it takes care that it is monotonic etc.



##########
sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaUnboundedReader.java:
##########
@@ -568,7 +577,22 @@ private void consumerPollLoop() {
       while (!closed.get()) {
         try {
           if (records.isEmpty()) {
+            // Each source has a single unique topic.
+            List<TopicPartition> topicPartitions = 
source.getSpec().getTopicPartitions();
+            Preconditions.checkStateNotNull(topicPartitions);
+            String topicName = "null"; // value will be overridden
+            for (TopicPartition topicPartition : topicPartitions) {
+              topicName = topicPartition.topic();

Review Comment:
   do this once in constructor? seems like source spec shoudl be unchanging?



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