Is there any way to convert incoming b3 trace headers to Elastic APM transactions

I've instrumented traefik to write to the Elastic APM Jaeger endpoint. My downstream services are however instrumented with Elastic APM and I'd like to keep them that way, especially with the richer instrumentation I get with go services.

Is there any way to transfer B3 headers (X-B3-Spanid, X-B3-Traceid, etc) to Elastic-Apm-Traceparent (which appears to be composed of a value separated by dashes)? I'd like to do so with a middleware that runs before the elastic apmhttp package so that I get the full end to end trace when using services that don't have apm support built in.

@Azuka yes, that is possible.

opencensus-go has some code which you could refer to for parsing the B3 headers: https://github.com/census-instrumentation/opencensus-go/blob/master/plugin/ochttp/propagation/b3/b3.go

After parsing, you would create a https://godoc.org/go.elastic.co/apm#TraceContext (leaving the State field empty). Finally, you can turn that back into an elastic-apm-traceparent header value with https://godoc.org/go.elastic.co/apm/module/apmhttp#FormatTraceparentHeader.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.