opentelemetry-go
opentelemetry-go copied to clipboard
OpenTracing bridge: BridgeTracer.Inject errors with ErrInvalidCarrier
Description
We are migrating our OpenTracing app to OpenTelemetry using the OpenTracing bridge. Unfortunately tracer.Inject
is failing with ErrInvalidCarrier
despite providing a valid HTTPHeaders
carrier.
The code:
- we are injecting a carrier with format
HTTPHeaders
here - our carrier
HttpgrpcHeadersCarrier
implementsTextMapWriter
as documented onHTTPHeaders
-
BridgeTracer
tries to cast this carrier into a HTTPHeadersCarrier which is not possible
Is this a known limitation of the OpenTracing bridge?
I'd guess to solve this we'd need some kind of adapter from the OpenTracing TextMapWriter
into OTel's TextMapCarrier
.
I see Inject
only calls Set
so maybe we can get away with only implementing that function?
Environment
- opentelemetry-go version: v1.0.0-RC2
- github.com/opentracing/opentracing-go: v1.2.0
Steps To Reproduce
- Use
BridgeTracer
from the OpenTracing bridge - Inject a carrier with format
HTTPHeaders
that implementsTextMapWriter
but is not of typeHTTPHeadersCarrier
Expected behavior
The BridgeTracer.Inject
should accept a carrier of type TextMapWriter
.
I started working on this.