Skip to content

Commit

Permalink
Add kafka poll latency metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Naireen committed Sep 26, 2024
1 parent c03a6e3 commit 3f9d233
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,14 @@ 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;
}

stopwatch.start();
records = consumer.poll(KAFKA_POLL_TIMEOUT.getMillis());
Expand Down Expand Up @@ -617,7 +625,6 @@ private void consumerPollLoop() {

private void commitCheckpointMark() {
KafkaCheckpointMark checkpointMark = finalizedCheckpointMark.getAndSet(null);

if (checkpointMark != null) {
LOG.debug("{}: Committing finalized checkpoint {}", this, checkpointMark);
Consumer<byte[], byte[]> consumer = Preconditions.checkStateNotNull(this.consumer);
Expand Down

0 comments on commit 3f9d233

Please sign in to comment.