yaboofzu opened a new issue, #10321: URL: https://github.com/apache/skywalking/issues/10321
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar issues. ### Apache SkyWalking Component Java Agent (apache/skywalking-java) ### What happened 在使用 jdk-threading-plugin和 kafka-plugin 增强的项目中,会出现TraceId 重复的情况 In projects enhanced with jdk-threading-plugin and kafka-plugin, duplicate TraceId can occur ### What you expected to happen Skywalking 需要管理插件之间的相互影响,保证TraceId 不能重复。 Skywalking manages the interactions between plug-ins to ensure that traceids cannot be repeated. ### How to reproduce 示例如下: for example: ``` @Component public class TestConsumer implements Runnable { private Logger logger = LoggerFactory.getLogger(this.getClass()); private KafkaConsumer<String, String> consumer; @Autowire private ExecutorService executorService; @PostConstruct public void initKafkaConsumer() { int threadNum = SysConfig.getInteger("worksheet.statistic.threads", Runtime.getRuntime().availableProcessors()); handleMap = AbstractHandler.getHandlerList(); consumer = new KafkaConsumer<>(worksheetKafkaClient.consumeProperties()); // 这里被jdk-threading-plugin 增强, 创建TraceContext // enhance by jdk-threading-plugin, generate TraceContext this.run(); } @Override public void run() { logger.info("consumer start "); try { while (running) { ConsumerRecords<String, String> poll = consumer.poll(200); logger.info("poll message"); for (ConsumerRecord<String, String> record : poll) { // Cn多线程创建的Trace上下文会传递到下游, // En:The Trace context created by multiple threads is passed downstream, //Cn:kafka-plugin 在上游TraceContext存在的情况下,无法再按照消息的维度重新生成TraceContext //En: kafka-plugin can't regenerate TraceContext based on the dimensions of the message if the upstream TraceContext exists // Cn:造成所有消息的 traceId 都重复掉了,引用了执行多线程方法的traceId // En: consumer message traceId repeat ,the traceId create by multiple threads not kafka executorService.submit(() -> processMessage(record)); } } } catch (WakeupException ex) { logger.info("wakeup consumer while running=" + running,ex); } catch (Exception e) { logger.error("kafka stopped!", e); } finally { try { consumer.close(); } catch (Exception e) { logger.error(String.format("close kafka consumer %s failed!", JSON.toJSONString(handleMap.keySet())), e); } } } } ``` ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
