Closed zxt47 closed 5 years ago
@zxt47 A simple implementation is to decorate the context of the current thread to the specified Runnable and finally reset the current thread context.
@glmapper
@zxt47 A simple implementation is to decorate the context of the current thread to the specified Runnable and finally reset the current thread context.
额,为什么这里不能使用InheritableThreadLocal或者阿里自研的transmittable-thread-local? 这里:
/**
* SofaTracerThreadLocalTraceContext
*
* @author yangguanchao
* @since 2018/05/01
*/
public class SofaTracerThreadLocalTraceContext implements SofaTraceContext {
private final ThreadLocal<SofaTracerSpan> threadLocal = new InheritableThreadLocal<>();
我这边通过自定义async的线程池,然后自定义线程池的TaskDecorator来实现的
My Question: Hello, guys, I want to know When My Project using Spring Async Annotation in order to start another asynchronous task, I will lose the traceID and spanID in the Main Thread,In my opinion, the context can't inherited? just like this blow:
2019-09-05 10:54:11,449 [TUMSMsgService-1] c.t.p.i.b.g.TumsServiceImplExample INFO [ac16b07b1567652051440100111292,0] >Start handle TUMS msg.MsgType:ARP,MsgContent:Ich liebe dich
then async begin:2019-09-05 10:54:07,312 [SimpleAsyncTaskExecutor-3] worklog INFO [,] >orisys is RCT_MU 2019-09-05 10:54:07,321 [SimpleAsyncTaskExecutor-3] worklog INFO [,] >MODE is CLIENT 2019-09-05 10:54:07,321 [SimpleAsyncTaskExecutor-3] worklog INFO [,] >servicename is RCT_MU 2019-09-05 10:54:07,321 [SimpleAsyncTaskExecutor-3] worklog INFO [,] >connectnum_put is 1 2019-09-05 10:54:07,321 [SimpleAsyncTaskExecutor-3] worklog INFO [,] >econnectnum_get is 1 2019-09-05 10:54:07,321 [SimpleAsyncTaskExecutor-3] worklog INFO [,] >qnameget=RCT_MU_INPUT
So how can I make the Spring Async have the Parent Thread's Span?**### Environment
java -version
):1.8uname -a
):MAC OS X and windows and RHEL7