Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not get mdc traceId #484

Open
LostZG opened this issue Sep 11, 2024 · 2 comments
Open

can not get mdc traceId #484

LostZG opened this issue Sep 11, 2024 · 2 comments

Comments

@LostZG
Copy link

LostZG commented Sep 11, 2024

Describe the bug
131726045310_ pic
it can be seen, http-nio-8881-exec-4 is my main thread,TaskMainSubExecutePool is the thread pool i started,
they can both get the traceId in mdc,
xcLogProducerThread is disruptor thread,but it can not get the traceId in mdc.
what is the cause of this? or how do i troubleshoot this problem? thks!

Expected behavior
can get mdc traceId

Desktop (please complete the following information):

  • OS: [mac os]
  • Version [13.5]
  • JVM Version [OpenJDK 1.8]
@rfoltyns
Copy link

I managed to reproduce it with a very specific Log4j2 pattern layout configuration. However, I don't want to make too many assumptions here. Could you please share all of the following:

  • logging configuration
  • list of logging dependencies on the classpath
  • list of system properties you used to configure the logging

@tcmot
Copy link

tcmot commented Sep 18, 2024

@LostZG
能不能获取到mdc traceId和disruptor没有任何关系的,disruptor不提供获取traceId的任何保证。

你应该检查自己的场景,mdc传递traceId的条件非常苛刻,threadlocal只能传递当前线程,InheritableThreadLocal只能传递子线程,无法传递线程池。

想要满足所有情况,需要使用阿里的TLL库进行包装。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants