From 0c5342e44480a49cf4c9b2f2a4c61251f7e09b36 Mon Sep 17 00:00:00 2001 From: Patrik Segedy Date: Wed, 18 Oct 2023 13:59:36 +0200 Subject: [PATCH] add trace logging for kafka headers --- base/mqueue/mqueue_impl_gokafka.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/base/mqueue/mqueue_impl_gokafka.go b/base/mqueue/mqueue_impl_gokafka.go index 7c51a3587..49c77c735 100644 --- a/base/mqueue/mqueue_impl_gokafka.go +++ b/base/mqueue/mqueue_impl_gokafka.go @@ -15,6 +15,7 @@ import ( "github.com/segmentio/kafka-go/sasl" kafkaPlain "github.com/segmentio/kafka-go/sasl/plain" kafkaScram "github.com/segmentio/kafka-go/sasl/scram" + log "github.com/sirupsen/logrus" ) type kafkaGoReaderImpl struct { @@ -31,6 +32,11 @@ func (t *kafkaGoReaderImpl) HandleMessages(handler MessageHandler) { utils.LogError("err", err.Error(), "unable to read message from Kafka reader") panic(err) } + if !log.IsLevelEnabled(log.TraceLevel) { + for _, h := range m.Headers { + utils.LogTrace("key", h.Key, "value", string(h.Value), "kafka message header") + } + } // At this level, all errors are fatal kafkaMessage := KafkaMessage{Key: m.Key, Value: m.Value} if err = handler(kafkaMessage); err != nil {