Skip to content

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

@yvrhdn

Description

@yvrhdn

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions