Skip to content

Commit

Permalink
Fix consumer cannot end the span of the last message
Browse files Browse the repository at this point in the history
  • Loading branch information
XSAM committed Jul 15, 2020
1 parent 6cd294b commit 8e48209
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions instrumentation/github.com/Shopify/sarama/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}()
Expand Down

0 comments on commit 8e48209

Please sign in to comment.