opentelemetry-go icon indicating copy to clipboard operation
opentelemetry-go copied to clipboard

Baggage is not propagated by OpenTracing bridge

Open bboreham opened this issue 2 years ago • 7 comments

Description

When using BridgeTracer, after Inject the Carrier has no entries for baggage. After Extract the resulting SpanContext has nil in the baggage field.

Environment

  • OS: Linux
  • Architecture: ARM64 (M1)
  • Go Version: go1.17.1 darwin/arm64
  • opentelemetry-go version: 1884de2b4b68aaf, shortly after v1.6.3

Steps To Reproduce

Starting with the test from #2141, add some baggage: https://github.com/bboreham/opentelemetry-go/commit/c162bddc5ca80999b5f4ead43fff6b57adac17c8

Observe the test now fails:

go test -run ^TestHeaderCarrier$ go.opentelemetry.io/otel/bridge/opentracing
--- FAIL: TestHeaderCarrier (0.00s)
    /Users/bryan/src/github.com/open-telemetry/opentelemetry-go/bridge/opentracing/bridge_test.go:93: Extracted span context does not match: 
&opentracing.bridgeSpanContext{bag:baggage.Baggage{list:baggage.List{"Foo":baggage.Item{Value:"bar", Properties:[]baggage.Property(nil)}}}, otelSpanContext:trace.SpanContext{traceID:trace.TraceID{0x5e, 0xb4, 0x86, 0x1, 0x52, 0xcc, 0x3b, 0x6a, 0xab, 0xdd, 0x71, 0x2f, 0xe7, 0x5a, 0x7d, 0x54}, spanID:trace.SpanID{0x41, 0x3f, 0xec, 0x7c, 0x4b, 0xec, 0xea, 0x13}, traceFlags:0x0, traceState:trace.TraceState{list:[]trace.member(nil)}, remote:false}}, 
&opentracing.bridgeSpanContext{bag:baggage.Baggage{list:baggage.List(nil)}, otelSpanContext:trace.SpanContext{traceID:trace.TraceID{0x5e, 0xb4, 0x86, 0x1, 0x52, 0xcc, 0x3b, 0x6a, 0xab, 0xdd, 0x71, 0x2f, 0xe7, 0x5a, 0x7d, 0x54}, spanID:trace.SpanID{0x41, 0x3f, 0xec, 0x7c, 0x4b, 0xec, 0xea, 0x13}, traceFlags:0x0, traceState:trace.TraceState{list:[]trace.member(nil)}, remote:true}}

Expected behavior

Baggage should be propagated.

Commentary

There are lines in BridgeTracer.Inject and Extract aimed at doing something with baggage: https://github.com/open-telemetry/opentelemetry-go/blob/1884de2b4b68aaf6e7613339b6d0b4397e5aa5c8/bridge/opentracing/bridge.go#L648 https://github.com/open-telemetry/opentelemetry-go/blob/1884de2b4b68aaf6e7613339b6d0b4397e5aa5c8/bridge/opentracing/bridge.go#L667

However the propagator Inject and Extract methods do not seem to line up with this code's expectations.

bboreham avatar Apr 18 '22 11:04 bboreham

Hi ,

Can I take this bug ?

anshul35 avatar May 19 '22 19:05 anshul35

@MrAlias @MadVikingGod I would like to work on this. Could you please provide me any entry point from where I can start ?

shubham-bansal96 avatar Apr 06 '23 11:04 shubham-bansal96

@bboreham I am not able to reproduce this issue, could you please provide me few more details regarding replicating steps ?

shubham-bansal96 avatar Apr 07 '23 11:04 shubham-bansal96

You tried the test at the commit I linked?

bboreham avatar Apr 07 '23 13:04 bboreham

Thanks @bboreham , Now i am able to reproduce this.

shubham-bansal96 avatar Apr 10 '23 16:04 shubham-bansal96

The following fixes the example given in https://github.com/bboreham/opentelemetry-go/commit/c162bddc5ca80999b5f4ead43fff6b57adac17c8

- otel.SetTextMapPropagator(propagation.TraceContext{})
+ otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}))

This is expected behaviour, I've written a test in #4776 to cover this.

No changes needed, happy to close this

scorpionknifes avatar Dec 21 '23 14:12 scorpionknifes

@bboreham Can you please check https://github.com/open-telemetry/opentelemetry-go/issues/2793#issuecomment-1866427747?

pellared avatar Dec 28 '23 09:12 pellared