PlaytikaOSS / sleuth-camel

MIT License
14 stars 8 forks source link

Trace id is not carried forwarded in case of threads() used in route #11

Open PradeepNain opened 3 years ago

PradeepNain commented 3 years ago

Hi, We are using sleuth camel. We get the traces from the API and carry forward the trace in b3 header to camel. Everything was working fine, but then we started using the threads() in the route, after that all the trace is not getting carried forward and is broken. We are not able to visualize the traces.

Before: working from(kafkaProperties) .routeId(ROUTE_ID) .process()..

After: Not working from(kafkaProperties) .threads() .executorService(executorService) .routeId(ROUTE_ID) .process()..

New traces are getting created per processor

tdanylchuk commented 3 years ago

Unfortunately, multithreading(splitting pipeline) is not supported by this lib, not sure if we going to invest time on that, but any help would be much appreciated.

PradeepNain commented 3 years ago

There are some tests though with threads https://github.com/Playtika/sleuth-camel/blob/develop/sleuth-camel-core/src/test/java/com/playtika/sleuth/camel/functional/TestApp.java#L87

PradeepNain commented 3 years ago

Found a way If you use TraceableExecutorService, it carries the trace id across. https://docs.spring.io/spring-cloud-sleuth/docs/current/reference/html/integrations.html#sleuth-async-executor-service-integration

I'll raise a PR with updated Readme.

TraceableExecutorService traceableExecutorService = new TraceableExecutorService(beanFactory, executorService);

from(kafkaProperties) .threads() .executorService(traceableExecutorService)