sofastack / sofa-tracer

SOFATracer is a component for the distributed system call trace. And through a unified traceId logging the logs of various network calls in the invoking link. These logs can be used for quick discovery of faults, service governance, etc.
Apache License 2.0
1.11k stars 375 forks source link

sofa-tracer-kafkamq-plugin支持ProducerListener解决方案 #488

Open keith-java opened 2 years ago

keith-java commented 2 years ago

sofa-tracer-kafkamq-plugin集成到sofa-boot足以满足常规生产/消费,有一种场景现在无法满足,请教一下实现方案

场景:kafka生产者异步回调实现中日志无法关联tracer

代码使用场景: 1、ListenableFuture 2、ProducerListener

如果需要支持以上两种代码的回调实现tracer功能,应该怎么实现

glmapper commented 2 years ago

@keith-java spanContext 的传递在消息场景依赖的是 消息头传递,理论上不管是同步还是异步,只要返回的消息头中存在 spanContext,就可以解析出来,然后塞到 MDC 中去以关联日志,可以尝试从这个思路解决。也欢迎提供 PR 支持此场景