Skip to content

Commit 861e102

Browse files
authored
Adds attempt number to log message when failing to write messages. This is done to make it easier to write better error logger implementations. For instance, when using IAM auth for MSK, the first write will fail after credentials rotate. The connection is re-negotiated and the retry is successful, but the logs are filled with errors. This lets us ignore the error of the first attempt, but log subsequent ones. (#1165)
1 parent 8ceaf94 commit 861e102

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

writer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ func (ptw *partitionWriter) writeBatch(batch *writeBatch) {
11561156
stats.errors.observe(1)
11571157

11581158
ptw.w.withErrorLogger(func(log Logger) {
1159-
log.Printf("error writing messages to %s (partition %d): %s", key.topic, key.partition, err)
1159+
log.Printf("error writing messages to %s (partition %d, attempt %d): %s", key.topic, key.partition, attempt, err)
11601160
})
11611161

11621162
if !isTemporary(err) && !isTransientNetworkError(err) {

0 commit comments

Comments
 (0)