1

I have one QuarkusMain app which calls a Quarkus API through RestClient

I annotated my run() method with @WithSpan and was able to get a spanId and a traceId in my QuarkusMain app:

 @Override
 @WithSpan
 public int run(String... args) {
   // my business logic
 }

The run method calls a REST service in another quarkus application through a RestClient interface. The issue is that I am not able to get the same traceId in my Quarkus API.

I saw here: https://quarkus.io/guides/opentelemetry that the context was automatically propagated. Am I missing something ?

Edit 1 with additional infos:

For instance, the log in my Quarkus main tells:

{"spanId":"1e0a6b40db4a3e24","traceId":"d9a4bc00ab3b2f576223de16f1026fc7","sampled":"true"}

The log in my Quarkus API:

{"spanId":"6b490589e3a7650d","parentId":"d7b1d6a2ab520e84","traceId":"079089560b1a4d0af84252a86bfa0e74","sampled":"true"}

And finally the traceparent header received by my API:

00-079089560b1a4d0af84252a86bfa0e74-d7b1d6a2ab520e84-01

We can see that the traceparent header matches the log in API level. So my conclusion is something is happening between the log in my main class and the call to the API. It seems that others spanId/traceId are generated before calling my api.

Edit 2 with resources and config:

Quarkus version: 2.16.4.Final

Dependency:

<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-opentelemetry</artifactId>
</dependency>

Config: quarkus.opentelemetry.enabled=true

godo57
  • 508
  • 2
  • 24
  • You're right the context should be propagated. Can you verify that the HTTP request generated by the RestClient has the traceparent header? This will help determine if the issue is with the client or the server side of the request. – Danny Dyla Mar 20 '23 at 12:46
  • Sometimes this kind of stuff works if a request scope is activate. Can you try the same code but placing `@ActivateContextRequest` on `run()` just for a test – Luca Basso Ricci Mar 20 '23 at 13:06
  • @DannyDyla there is indeed a traceparent header with this value: `00-079089560b1a4d0af84252a86bfa0e74-d7b1d6a2ab520e84-01`. The log in the quarkus main tells: `{"spanId":"1e0a6b40db4a3e24","traceId":"d9a4bc00ab3b2f576223de16f1026fc7","sampled":"true"}`. And the log in my API tells: `{"spanId":"6b490589e3a7650d","parentId":"d7b1d6a2ab520e84","traceId":"079089560b1a4d0af84252a86bfa0e74","sampled":"true"}` – godo57 Mar 20 '23 at 13:12
  • @LucaBassoRicci thanks for the tip but unfortunately, the traceId is not the same even if I add the annotation. – godo57 Mar 20 '23 at 13:16
  • The span ID logged in the client may not be the span id sent in the request. There is a separate span for the HTTP call itself which would be the child of the span logged in your `run` method. To me, it looks like this is working correctly. Are you exporting span data somewhere? – Danny Dyla Mar 20 '23 at 16:06
  • What version of Quarkus are you using? As I understood. You have a quarkus service sending HTTP client calls and a Quarkus server receiving them, Right? Do you have a configured sampler (the logs hint to that)? ... Remember that sampled traces will not be sent by the exporter. Do you see the original span on Jaeger? – Bruno Baptista Mar 20 '23 at 18:39
  • @DannyDyla, I agree about the different spanIds, but as I understand, the traceIds must be the same. This is not the case here. – godo57 Mar 21 '23 at 06:13
  • Can you please share the dependencies you are using and the config? – Bruno Baptista Mar 21 '23 at 10:09
  • @BrunoBaptista I edit with some config info. – godo57 Mar 21 '23 at 10:14
  • Ah sorry I didn't see the trace id changed. You are correct they should be the same. It is weird that the trace id logged in the client is different than the one actually in the header. Do you by chance have any other instrumentation agents (possibly a vendor agent of some kind) installed? – Danny Dyla Mar 21 '23 at 14:51
  • Also, is there anything between the client and the API such as a load balancer that might be adding or modifying headers? – Danny Dyla Mar 21 '23 at 14:54
  • Which rest client are you using to perform the call? Also, on the server side, what is the version and the configs you are using? – Bruno Baptista Mar 21 '23 at 15:02
  • No load balancer, I work in my local machine. The only thing I have in my client app is `prometheus`. I use the standard RestClient of microprofile. – godo57 Mar 23 '23 at 08:13
  • Did you figure out why this happening? I am noticing the same with 2 Quarkus services where I have WithSpan and application.properties changes but then the trace id is different between services – sg1973 Jun 18 '23 at 13:17

0 Answers0