| 337 | } |
| 338 | |
| 339 | func produceErrReason(err error) string { |
| 340 | if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, kgo.ErrRecordTimeout) { |
| 341 | return "timeout" |
| 342 | } |
| 343 | if errors.Is(err, kgo.ErrMaxBuffered) { |
| 344 | return "buffer-full" |
| 345 | } |
| 346 | if errors.Is(err, kerr.MessageTooLarge) { |
| 347 | return "record-too-large" |
| 348 | } |
| 349 | if errors.Is(err, context.Canceled) { |
| 350 | // This should never happen because we don't cancel produce requests, however we |
| 351 | // check this error anyway to detect if something unexpected happened. |
| 352 | return "canceled" |
| 353 | } |
| 354 | return "other" |
| 355 | } |