最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

trace - trace_id is not passed to worker threads using opentelmnetry with jaeger - Stack Overflow

programmeradmin1浏览0评论

I am trying to integrate my service with opentelmentry to trace the service flow . Tracing tool : Yaeger

Note : I cannot go with javaagent becuase yaeger-exporter is not supoprted in latest version of javaagent . ()

My requirement is to maintain the same trace throughout even if the worker / executor threads are triggered in between , but currently this is not happening .

Code Block :

String traceId = getCurrentTraceId();
 logger.info("Pran Traceid in Service "+ traceId);
 executor.submit(runnableTask);

                    
                            

output :

2024-11-19 10:01:43,851 | INFO  |[74230bef15e61516c4165702fcf04cee]|[c021715ac9e96148]| 33, **http-nio-8080-exec-1** |  | Service |  |  |  |  | Pran Traceid in Service 74230bef15e61516c4165702fcf04cee
2024-11-18 14:51:22,465 | INFO  |[]|[]| 53, **pool-4-thread-1** |  | Application |  |  |  |  | run method triggered from Executors

I tried adding MDC to maintain the context but that didnot work with opentelmentry as MDC.get("traceId") is always coming as null

**

String traceId = MDC.get("traceId");
MDC.put("traceId", traceId);
 try {
                // Set the MDC context in the worker thread
                MDC.put("traceId", traceId);
                task.run();
            } finally {
                // Clean up the MDC context after execution
                MDC.clear();
      }

**

发布评论

评论列表(0)

  1. 暂无评论