From 565336280ad95969c8431e0b5c34d6ef89c4c58e Mon Sep 17 00:00:00 2001 From: Helen Weller <38860767+helenosheaa@users.noreply.github.com> Date: Thu, 25 Mar 2021 18:06:03 -0400 Subject: [PATCH] moved samara config out of init into connect (#9051) --- plugins/outputs/kafka/kafka.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/outputs/kafka/kafka.go b/plugins/outputs/kafka/kafka.go index 5aad62f48e408..d30c730cfac18 100644 --- a/plugins/outputs/kafka/kafka.go +++ b/plugins/outputs/kafka/kafka.go @@ -43,6 +43,7 @@ type Kafka struct { Log telegraf.Logger `toml:"-"` + saramaConfig *sarama.Config producerFunc func(addrs []string, config *sarama.Config) (sarama.SyncProducer, error) producer sarama.SyncProducer @@ -278,6 +279,8 @@ func (k *Kafka) Init() error { return err } + k.saramaConfig = config + // Legacy support ssl config if k.Certificate != "" { k.TLSCert = k.Certificate @@ -285,15 +288,15 @@ func (k *Kafka) Init() error { k.TLSKey = k.Key } - producer, err := k.producerFunc(k.Brokers, config) - if err != nil { - return err - } - k.producer = producer return nil } func (k *Kafka) Connect() error { + producer, err := k.producerFunc(k.Brokers, k.saramaConfig) + if err != nil { + return err + } + k.producer = producer return nil }