I'm developing an application with 2 microservices: Microservice A sends data to kafka broker and Microservice B consumes records from kafka and stores data into mysql db. My goal is to get the full trace of a request, starting from the Microservice A that receives a POST request, passing through kafka and ending in Microservice B, propagating the opentelemetry traceId generated in the Microservice A into Microservice B logs. Opentelemetry uses W3C standard to propagate the context. I'm able to inject into the kafka record header parameter traceParent the corrent traceId using
@Inject
@Channel("channel-out")
Emitter<MyData> emitter;
...
emitter.send(Message.of(myData, Metadata.of(TracingMetadata.withCurrent(Context.current()))));
on the Microservice A side, but on the Microservice B side I'm not able to get the propagated context. Microservice B consumes record using
@Incoming("channel-in")
public void myFunction(MyData d) {...}
I'm expecting that on the Microservice B side is used the same traceId injected on the traceParent parameter of the kafka record, but if I check the traceId using
Span.current().getSpanContext().getTraceId()
it's all zeros, that is an invalid value for W3C standard.
I'm using Java as language and Quarkus as framework, opentelemetry and smallrye reactive messaging for kafka.
Can anyone help me? Thanks.