apm-agent-go
apm-agent-go copied to clipboard
Issue in converting between OTEL and APM context
Describe the bug
Information seems to be getting lost between converting from an APM context to OTEL context.
-
If we have a OTEL parent span and APM child span, we can see full relationship in Kibana. The figure below shows how we go from
elasticHandler(otel) ->Streaming(apm) ->Semaphore.Acquire(apm) -
The issue arises when we want to go from an APM span back to an OTEL span. In this case, we do not observe the last span (
Semaphore.Acquire) in Kibana.
To Reproduce
- Create an OTEL parent span. Then an APM child span, followed by another APM child span. View in Kibana
- Create an OTEL parent span. Then an APM child span, followed by an OTEL child span. View in Kibana
Expected behavior
Spans and Span Links that go from OTEL context to APM context doesn't work.
Nice find. It looks like this is because the APM span is a child span. We only look for transactions when checking parent spans from apm. https://github.com/elastic/apm-agent-go/blob/2b38f4b760d1998800da0c05b9a654e867395afd/module/apmotel/tracer.go#L77-L79
My bad. We actually connect the span when it's created within the apm agent, through the wrapper. https://github.com/elastic/apm-agent-go/blob/2b38f4b760d1998800da0c05b9a654e867395afd/module/apmotel/wrapper.go#L45
How are you creating the Stream span? Are you assigning it to the context?
@rubvs ping?
@dmathieu Sorry, I was on PTO for 2 weeks. Here is how the Stream span is created, see Code. The context passed to this span is from an OTEL parent span.
I'm not seeing apmotel being required in apm-data (nor the service using it).
In order to be able to properly link spans together, apmotel need to be imported into the application, and the tracer provider needs to be configured, as is documented here: https://www.elastic.co/guide/en/apm/agent/go/current/opentelemetry.html