diff --git a/instrumentation/github.com/Shopify/sarama/consumer.go b/instrumentation/github.com/Shopify/sarama/consumer.go index 7eb3afc4f66..b945a037c41 100644 --- a/instrumentation/github.com/Shopify/sarama/consumer.go +++ b/instrumentation/github.com/Shopify/sarama/consumer.go @@ -48,7 +48,6 @@ func WrapPartitionConsumer(serviceName string, pc sarama.PartitionConsumer, opts go func() { msgs := pc.Messages() - var prevSpan trace.Span for msg := range msgs { // Extract a span context from message to link. carrier := NewConsumerMessageCarrier(msg) @@ -79,15 +78,7 @@ func WrapPartitionConsumer(serviceName string, pc sarama.PartitionConsumer, opts // Send messages back to user. wrapped.messages <- msg - // Finish the previous span. - if prevSpan != nil { - prevSpan.End() - } - prevSpan = span - } - // Finish any remaining span. - if prevSpan != nil { - prevSpan.End() + span.End() } close(wrapped.messages) }()