From 6cd294b7e6529637fbc350a14e19c728ac98246b Mon Sep 17 00:00:00 2001 From: Sam Xie Date: Wed, 15 Jul 2020 16:58:24 +0800 Subject: [PATCH] Fix async producer cannot return successes once been closed --- instrumentation/github.com/Shopify/sarama/producer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instrumentation/github.com/Shopify/sarama/producer.go b/instrumentation/github.com/Shopify/sarama/producer.go index 84f968c3747..c604676101c 100644 --- a/instrumentation/github.com/Shopify/sarama/producer.go +++ b/instrumentation/github.com/Shopify/sarama/producer.go @@ -143,7 +143,9 @@ func WrapAsyncProducer(serviceName string, saramaConfig *sarama.Config, p sarama case t := <-wrapped.close: switch t { case closeSync: - wrapped.closeErr <- p.Close() + go func() { + wrapped.closeErr <- p.Close() + }() case closeAsync: p.AsyncClose() }