Getting different trace Id when calling @Async calls in Java, using open telemetry manual instrumentation #12112
-
I'm using java manual instrumentation of open telemetry but receiving different trace Id even after using scope of open telemetry while using async calls My Open telemetry configuration class @configuration
} package com.broadridge.ics.unptl.service; import io.opentelemetry.api.trace.Span; @service
} I have an endpoint /getData in Controller @Autowired public String getDate(Request request) } Service : public String getDataFromService(Request request) Component: @async("AsyncExecutor") @async("AsyncExecutor") Span serviceSpan = opentelemetryService.serviceSpan("CompletableFutureHandler",tracer); how to fix it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
When using manual instrumentation there is no automatic context propagation between threads, you'll have to take care of it on your own. One way to achieve this would be to wrap the executor using https://github.com/open-telemetry/opentelemetry-java/blob/7522bfe141524d52649b5c344c643104b57af608/context/src/main/java/io/opentelemetry/context/Context.java#L119 |
Beta Was this translation helpful? Give feedback.
-
Adding it the executor worked. Thank you!! @laurit |
Beta Was this translation helpful? Give feedback.
When using manual instrumentation there is no automatic context propagation between threads, you'll have to take care of it on your own. One way to achieve this would be to wrap the executor using https://github.com/open-telemetry/opentelemetry-java/blob/7522bfe141524d52649b5c344c643104b57af608/context/src/main/java/io/opentelemetry/context/Context.java#L119