admin管理员组

文章数量:1334339

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();
      }

**

本文标签: tracetraceid is not passed to worker threads using opentelmnetry with jaegerStack Overflow