You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add "human readable" description for offset in reader logs (#893)
When the reader logs an offset value, if the value is a special value,
i.e. FirstOffset / LastOffset, it will log something like
setting the offset ... from -2 to 20
With this change, it'll say "first offset" or "last offset",
respectively, for example:
setting the offset ... from first offset to 20
It uses a new `fmt.Formatter` type, `humanOffset`, which seems more
expressive (and performant) that simply converting to a string.
Instead of type-casting offset directly, I added a helper
`toHumanOffset` to avoid other types, e.g. `humanOffset(uint64(1))`.
Co-authored-by: Wade Carpenter <[email protected]>
log.Printf("failed to read from current broker for partition %d of %s at offset %d, topic or parition not found on this broker, %v", r.partition, r.topic, offset, r.brokers)
1323
+
log.Printf("failed to read from current broker for partition %d of %s at offset %d, topic or parition not found on this broker, %v", r.partition, r.topic, toHumanOffset(offset), r.brokers)
// Timeout on the kafka side, this can be safely retried.
1346
1346
errcount=0
1347
1347
r.withLogger(func(logLogger) {
1348
-
log.Printf("no messages received from kafka within the allocated time for partition %d of %s at offset %d", r.partition, r.topic, offset)
1348
+
log.Printf("no messages received from kafka within the allocated time for partition %d of %s at offset %d", r.partition, r.topic, toHumanOffset(offset))
log.Printf("the kafka reader is reading before the first offset for partition %d of %s, skipping from offset %d to %d (%d messages)", r.partition, r.topic, offset, first, first-offset)
1366
+
log.Printf("the kafka reader is reading before the first offset for partition %d of %s, skipping from offset %d to %d (%d messages)", r.partition, r.topic, toHumanOffset(offset), first, first-offset)
1367
1367
})
1368
1368
offset, errcount=first, 0
1369
1369
continue// retry immediately so we don't keep falling behind due to the backoff
0 commit comments