Closed nepoch closed 4 years ago
『TtlTransformer
类的transform
实现返回EMPTY_BYTE_ARRAY = {}
』的原因参见 https://github.com/alibaba/transmittable-thread-local/pull/68#issuecomment-232903425 :
用 empty array 来自代码质量改进的一个pull request #56 你可以从commit log( 4a5b292719a99414d9b46394544dc370bc27653f )里查到。
我看持续集成多jdk版本都是通过的,就接纳了这个pr。 https://github.com/alibaba/transmittable-thread-local/pull/68#issuecomment-232882555
即 使用 empty array 而不是 null
,是因为 优的代码实践,且 功能是OK的(JDK Agent
有效支持)。
从你提供的问题来看,使用pinpoint
,并不能,像使用JDK Agent
一样,有效支持empty array的返回。
我改一下,发一个新版本。 @nepoch
ClassFileTransformer
接口transform
方法的JavaDoc
的返回值要求已发布了 v2.11.1
:
https://github.com/alibaba/transmittable-thread-local/releases/tag/v2.11.1
@nepoch 使用新版本测试一下,是不是 OK了? ❤️
已发布了
v2.11.1
: https://github.com/alibaba/transmittable-thread-local/releases/tag/v2.11.1@nepoch 使用新版本测试一下,是不是 OK了? ❤️
@oldratlee 更新后测试正常,谢谢啦。
@nepoch pinpoint已经支持了异步上下文透传,你们的使用场景方便告诉一下么?
为了传递业务上的 ThreadLocal 而非 tracing 的 threadlocal 么?
@nepoch pinpoint已经支持了异步上下文透传,你们的使用场景方便告诉一下么?
为了传递业务上的 ThreadLocal 而非 tracing 的 threadlocal 么?
嗯嗯,有一些业务数据的传递。而且在线程池场景下也要拿到业务数据。我测试了pinpoint1.8.1版本,在使用线程池情况下也拿不到trx_id,所以直接集成了TTL。
@nepoch pinpoint已经支持了异步上下文透传,你们的使用场景方便告诉一下么?
为了传递业务上的 ThreadLocal 而非 tracing 的 threadlocal 么?
@hoverwinter 我们想在日志中记录每个请求的trace_id来实现日志全链路查询等功能,但pinpoint采样后,有些请求的trx_id没有,以及跨线程也会断掉。
所以我们就想在Pinpoint中集成transmittable-thread-local,来实现跨线程的日志全链路追踪。
不知道您有什么其他好的建议没
Use version:
pinpoint
: 1.8.1TTL
: 2.11.0Error when added
TtlAgent.premain (agentArgs, inst);
to the startup class ofpinpoint
. And finally found out:TtlTransformer
class implements theClassFileTransformer
interfacetransform
and returnsEMPTY_BYTE_ARRAY = ()
directly for non-enhanced classesI see return value description of
JavaDoc
forTransform
method ofClassFileTransformer
interface isIt should mean that if it is not enhanced, it should return
null
.I tried changing the source code to return
null
instead of{}
, and the program runs normally.Is there any special purpose for the
transform
implementation of theTtlTransformer
class to returnEMPTY_BYTE_ARRAY = {}
? Is there any other impact of changing to returningnull
here?使用版本
pinpoint
: 1.8.1TTL
: 2.11.0在
pinpoint
的启动类中加入了TtlAgent.premain(agentArgs, inst);
后报错,最后排查到:TtlTransformer
类实现ClassFileTransformer
接口transform
是对于不增强的类直接返回了EMPTY_BYTE_ARRAY = {}
我看
ClassFileTransformer
接口的transform
方法JavaDoc
的返回值说明是意思应该是说如果不做增强的话应该返回
null
这样我试了改源码成返回
null
而不是{}
,程序运行正常。TtlTransformer
类的transform
实现返回EMPTY_BYTE_ARRAY = {}
是有什么特殊用意吗?这里改成返回null
会不会有什么其他影响?