From cdd884afc0d02e4b76f00660aaa65939c4288d38 Mon Sep 17 00:00:00 2001 From: Almog Gavra Date: Tue, 7 Jan 2025 19:05:17 -0800 Subject: [PATCH] MINOR: improve StreamThread periodic processing log --- .../streams/processor/internals/StreamThread.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java index 2d9c1b0b11b03..d2ff9ff22eae8 100644 --- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java +++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java @@ -311,6 +311,7 @@ public boolean isStartingRunningOrPartitionAssigned() { private long lastLogSummaryMs = -1L; private long totalRecordsProcessedSinceLastSummary = 0L; private long totalPunctuatorsSinceLastSummary = 0L; + private long totalPolledSinceLastSummary = 0L; private long totalCommittedSinceLastSummary = 0L; private long now; @@ -960,6 +961,7 @@ void runOnceWithoutProcessingThreads() { final long pollLatency; taskManager.resumePollingForPartitionsWithAvailableSpace(); pollLatency = pollPhase(); + totalPolledSinceLastSummary += 1; // Shutdown hook could potentially be triggered and transit the thread state to PENDING_SHUTDOWN during #pollRequests(). // The task manager internal states could be uninitialized if the state transition happens during #onPartitionsAssigned(). @@ -1075,12 +1077,14 @@ void runOnceWithoutProcessingThreads() { pollRatioSensor.record((double) pollLatency / runOnceLatency, now); commitRatioSensor.record((double) totalCommitLatency / runOnceLatency, now); - if (logSummaryIntervalMs > 0 && now - lastLogSummaryMs > logSummaryIntervalMs) { - log.info("Processed {} total records, ran {} punctuators, and committed {} total tasks since the last update", - totalRecordsProcessedSinceLastSummary, totalPunctuatorsSinceLastSummary, totalCommittedSinceLastSummary); + final long timeSinceLastLog = now - lastLogSummaryMs; + if (logSummaryIntervalMs > 0 && timeSinceLastLog > logSummaryIntervalMs) { + log.info("Processed {} total records, ran {} punctuators, polled {} times and committed {} total tasks since the last update {}ms ago", + totalRecordsProcessedSinceLastSummary, totalPunctuatorsSinceLastSummary, totalPolledSinceLastSummary, totalCommittedSinceLastSummary, timeSinceLastLog); totalRecordsProcessedSinceLastSummary = 0L; totalPunctuatorsSinceLastSummary = 0L; + totalPolledSinceLastSummary = 0L; totalCommittedSinceLastSummary = 0L; lastLogSummaryMs = now; }