Integration with Sleuth for distributed tracing when using Parallel workflow #22
-
|
Currently, when integrating flowret with Spring cloud sleuth for distributed log tracing, the traceId is not propagated when using parallel workflows. This is because new threads are created in a parallel workflow and flowret uses ThreadPoolExecutor, and this implementation is not extendable (so, we cannot use any other option such as LazyTraceExecutor or LazyTraceThreadPoolTaskExecutor) The traceId is successfully propagated when a sequential workflow is used, because it works on the parent/caller thread. Can flowret be made either extensible in a way that a different ThreadPoolExecutor can be used or more control can be given to the user of the library on how any new threads are created? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
|
Understood your issue. I have a couple of options to address this. First is to allow the clients to create their own ExecutorService which Flowret can use. This problem I see with this approach is that Flowret will not have any control on the blocking queue used in the ExecutorService. This is an issue because I would like to retain the use of a bounded blocking queue such that the rejected item handled never gets invoked. I want to do this because in case the bounded queue is full, I would like to block rather than execute on the current thread. I have seen use cases where running on the current thread has caused problems. Second is to allow the clients to pass in their own implementation of a ThreadFactory to Flowret. Clients could create their own thread factory and set whatever information they want in the threads created which Flowret can use. I would prefer to use this method. Will the second option work for you? If so, I will go ahead and do the change in the next couple of days. |
Beta Was this translation helpful? Give feedback.
Hi - I have release a new version (1.4.2) in which I have introduced a new way to do parallel processing. The documentation has been updated. You could look it up there - providing the explanation here too - what you need to do is to specify the value of maxThreads as 0 in the init method. When you do that, Flowret will not create the Executor Service thread pool and will instead create threads on the fly whenever needed. This means that there will not be an upper bound on the maximum number of threads that can be created / used. But, since it is the parent thread which is creating the child threads, it will be possible to propagate the context from the parent to the child thread for exam…