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

OpenTracing bridge: BridgeTracing warns about deferred context setup, but how can this be avoided?

Open yvrhdn opened this issue 4 years ago • 0 comments

Description

I'm missing some documentation or examples of correct usage of the OpenTracing bridge. (I don't mind contributing this, but I'm not sure if my setup is correct.)

This is our code:

tp := tracesdk.NewTracerProvider(
	// ...
)
otel.SetTracerProvider(tp)

// ... omitted defer func to shutdown tp ...

// Install the OpenTracing bridge
bridgeTracer, _ := opentracing.NewTracerPair(tp.Tracer("OpenTracing"))
bridgeTracer.SetWarningHandler(func(msg string) {
	// ...
})
ot.SetGlobalTracer(bridgeTracer)

When I run this I always get the following warning:

SDK should have deferred the context setup, see the documentation of go.opentelemetry.io/otel/bridge/opentracing/migration

This is emitted by BridgeTracer when the context was modified by its OTel tracer. The BridgeTracer is using an instance of WrapperTracer, which respects the skip context setup. But I noticed WrapperTracer itself calls another tracer. What is stopping this tracer from modifying the context it returns?

In fact, the tracer in sdk/trace modifies the context and is thus not compatible I guess?

Is this warning thus unavoidable? Our exported traces seem fine so I'm not sure what to do with this warning.

yvrhdn avatar Jul 29 '21 17:07 yvrhdn