Skip to content

Commit

Permalink
contrib/confluentinc/confluent-kafka-go/kafka: fix TestDeprecatedContext
Browse files Browse the repository at this point in the history
  • Loading branch information
darccio committed Mar 21, 2024
1 parent 6e6db3f commit 0855dc0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ func TestDeprecatedContext(t *testing.T) {
"session.timeout.ms": 10,
"enable.auto.offset.store": false,
}, WithContext(ctx)) // Adds the parent context containing a span
assert.NoError(t, err)

err = c.Subscribe(testTopic, nil)
assert.NoError(t, err)
Expand All @@ -313,30 +314,28 @@ func TestDeprecatedContext(t *testing.T) {

// Inject the span context in the message to be produced
carrier := NewMessageCarrier(msg)
tracer.Inject(messageSpan.Context(), carrier)
tracer.Inject(parentSpan.Context(), carrier)

c.Consumer.Events() <- msg

}()

msg := (<-c.Events()).(*kafka.Message)

// Extract the context from the message
carrier := NewMessageCarrier(msg)
spanContext, err := tracer.Extract(carrier)
rcvMsgSpanContext, err := tracer.Extract(carrier)
assert.NoError(t, err)

parentContext := parentSpan.Context()

/// The context passed is the one from the parent context
assert.EqualValues(t, parentContext.TraceID(), spanContext.TraceID())
assert.EqualValues(t, parentContext.TraceID(), rcvMsgSpanContext.TraceID())
/// The context passed is not the one passed in the message
assert.NotEqualValues(t, messageSpanContext.TraceID(), spanContext.TraceID())
assert.NotEqualValues(t, messageSpanContext.TraceID(), rcvMsgSpanContext.TraceID())

c.Close()
// wait for the events channel to be closed
<-c.Events()

}

func TestCustomTags(t *testing.T) {
Expand Down

0 comments on commit 0855dc0

Please sign in to comment.