We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
问题一: 我们使用ttl的场景是用来做链路追踪,每个request都会在当前线程生成一个trace id,存放进ttl里,进而传递给子线程。这种情况下似乎restore操作没有什么意义,是否可以省略restore操作?
问题二: TransmittableThreadLocal.Transmitter.Snapshot这个类里,有2个属性,分别是ttl2Value和 threadLocal2Value。使用ttl时,都是围绕着备份和传递ttl2Value这个属性。这个时候,threadLocal2Value存在的意义是什么呢?
The text was updated successfully, but these errors were encountered:
对于你这个具体场景,『省略restore操作』不会有 功能上的问题(或说逻辑Bug)。 当然从性能上来看,有restore操作好处是可以尽早的安全释放,对内存/GC也更优的。
restore
Bug
GC
对于通用的场景(比如不是每次都设置的场景), 如果不清理,会导致上下文污染的问题(这样的Bug,在线上屡见不鲜)。
PS: 相关/类似问题的Issue:
threadLocal2Value字段用于『ThreadLocal集成』功能。
threadLocal2Value
ThreadLocal
参见 Issue #155 Transmitter类中的变量threadLocalHolder有什么用
更多说明参见: Transmitter代码上的 Javadoc https://alibaba.github.io/transmittable-thread-local/apidocs/2.11.5/com/alibaba/ttl/TransmittableThreadLocal.Transmitter.html Issue: ThreadLocal integration ThreadLocal integration #130
更多说明参见:
Transmitter
更多了解可以看一下TransmittableThreadLocal的资料/文档: @alexkuku ❤️
TransmittableThreadLocal
Sorry, something went wrong.
好的,看明白了,多谢!
oldratlee
No branches or pull requests
问题一:
我们使用ttl的场景是用来做链路追踪,每个request都会在当前线程生成一个trace id,存放进ttl里,进而传递给子线程。这种情况下似乎restore操作没有什么意义,是否可以省略restore操作?
问题二:
TransmittableThreadLocal.Transmitter.Snapshot这个类里,有2个属性,分别是ttl2Value和 threadLocal2Value。使用ttl时,都是围绕着备份和传递ttl2Value这个属性。这个时候,threadLocal2Value存在的意义是什么呢?
The text was updated successfully, but these errors were encountered: