How to collect and pass b3 propagation headers in grpc client request using opentracing api?

2.6k views Asked by At

I was using https://github.com/opentracing-contrib/java-grpc with jaegar tracer for enabling tracing in my grpc client program. Now I would like to use istio service mesh to handle tracing in server side. https://istio.io/latest/docs/tasks/observability/distributed-tracing/overview/ . So the grpc client now needs to send the appropriate tracing HTTP headers along with each grpc client request so that istio can send those metrics to Jaegar. Does anyone have a working example of fetching the trace span information in grpc client and include the corresponding b3 propagation headers in a grpc client request?

Following http headers need to be passed in a java/C# grpc client request :

  • x-request-id
  • x-b3-traceid
  • x-b3-spanid
  • x-b3-parentspanid
  • x-b3-sampled
  • x-b3-flags
  • x-ot-span-context

Thanks.

1

There are 1 answers

0
Kevin Brady On

Have a look at the OpenTelemetry-Java-Instrumentation project. It can provide automated tracing of your application without needing to write custom code. It uses an instrumentation agent that runs in the JVM beside your application.

java -javaagent:path/to/opentelemetry-javaagent-all.jar \
     -jar myapp.jar

It supports exporting metrics to Jaeger

It also supports propagating headers to downstream requests.

They have just added support for b3-multi headers so a new release should be available in the coming days