Skip to content

Commit

Permalink
[logging] fix consume rate logging bug to respect 1 minute threshold (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
jadami10 committed Aug 25, 2023
1 parent d91e5db commit 2b40362
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1648,14 +1648,15 @@ private void updateCurrentDocumentCountMetrics() {
_lastUpdatedRowsIndexed.set(_numRowsIndexed);
final long now = now();
final int rowsConsumed = _numRowsConsumed - _lastConsumedCount;
final long prevTime = _lastConsumedCount == 0 ? _consumeStartTime : _lastLogTime;
final long prevTime = _lastLogTime == 0 ? _consumeStartTime : _lastLogTime;
// Log every minute or 100k events
if (now - prevTime > TimeUnit.MINUTES.toMillis(TIME_THRESHOLD_FOR_LOG_MINUTES)
|| rowsConsumed >= MSG_COUNT_THRESHOLD_FOR_LOG) {
// multiply by 1000 to get events/sec. now and prevTime are in milliseconds.
float consumedRate = ((float) rowsConsumed) * 1000 / (now - prevTime);
_segmentLogger.info(
"Consumed {} events from (rate:{}/s), currentOffset={}, numRowsConsumedSoFar={}, numRowsIndexedSoFar={}",
rowsConsumed, (float) (rowsConsumed) * 1000 / (now - prevTime), _currentOffset, _numRowsConsumed,
_numRowsIndexed);
rowsConsumed, consumedRate, _currentOffset, _numRowsConsumed, _numRowsIndexed);
_lastConsumedCount = _numRowsConsumed;
_lastLogTime = now;
}
Expand Down

0 comments on commit 2b40362

Please sign in to comment.