Generating Tracing across languages (Java & C++)

We are using opentracing / jaeger tracing libraries in our project, and they worked fine for Java / SpringBoot / SpringCloud projects. All traces can be got and the jaeger tracing library automatically did 99% of work for your (Controller, RestTemplate, FeignClient, etc).

Now comes the problem. There is one java service will call a C++ service. We want the traces / spans to be shown in JaegerUI for both Java and C++, with their call hierarchy.

Unfortunately there is no much info for this online. After a few days of testing, I think I finally figured it out. The following is details.

  1. Compile your C++ project with opentracing & jaeger tracing libraries. This can be referred to official documents for C++ Jager tracing.
  2. Java Side. A simple Restful Controller. It calls the C++ service by RestTemplate. Jaeger for Java will automatically add the tracing headers on the http request.

3. C++ part.

And now we can test. Start Java and C++ project. Access the Java Restful controller.

And finally in JaegerUI, we can see the one trace with 2 spans are logged. The C++ span is shown as children of Java span.

The only thing which is difficult is in C++, how to create a child span with the given parent info. Hope community can update the documents soon.

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store