Skip to content

Commit

Permalink
refactor(backend): local Kafka errors logged on warning level
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgacsal committed Jul 15, 2024
1 parent e56de4c commit bb795e9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/ingest/kafkaingest/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,19 @@ func KafkaProducerGroup(ctx context.Context, producer *kafka.Producer, logger *s
// as the underlying client will automatically try to
// recover from any errors encountered, the application
// does not need to take action on them.
logger.Error("kafka error", "error", ev)
attrs := []any{
slog.Int("code", int(ev.Code())),
slog.String("error", ev.Error()),
}

// Log Kafka client "local" errors on warning level as those are mostly informational and the client is
// able to handle/recover from them automatically.
// See: https://github.com/confluentinc/librdkafka/blob/master/src/rdkafka.h#L415
if ev.Code() <= -100 {
logger.Warn("kafka local error", attrs...)
} else {
logger.Error("kafka broker error", attrs...)
}
}
case <-ctx.Done():
return ctx.Err()
Expand Down

0 comments on commit bb795e9

Please sign in to comment.