From 309f1952a9703875ff9250e1aa83a6fe03f8e071 Mon Sep 17 00:00:00 2001 From: luhualin Date: Thu, 26 Nov 2020 19:05:58 +0800 Subject: [PATCH] fix collector panic due to sarama sdk --- plugin/storage/kafka/writer.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin/storage/kafka/writer.go b/plugin/storage/kafka/writer.go index e82ecea735cf..2664beff90ba 100644 --- a/plugin/storage/kafka/writer.go +++ b/plugin/storage/kafka/writer.go @@ -57,8 +57,10 @@ func NewSpanWriter( }() go func() { for e := range producer.Errors() { - logger.Error(e.Err.Error()) - writeMetrics.SpansWrittenFailure.Inc(1) + if e != nil && e.Err != nil { + logger.Error(e.Err.Error()) + writeMetrics.SpansWrittenFailure.Inc(1) + } } }()