GuoHaoZai opened a new issue, #13204:
URL: https://github.com/apache/skywalking/issues/13204

   ### 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
   
   OAP server (apache/skywalking)
   
   ### What happened
   
   CompletableFuture#runAsync(Runnable runnable,Executor executor)
   If print logs in runnable, traceId will not be printed in the log
   
   Essentially, there is a problem with 
java.util.concurrent.ThreadPoolExecutor#execute(Runnable runnable). If Runnable 
extends ForkJoinTask, Runnable will not be enhanced.
   
   ### What you expected to happen
   
   apm-jdk-threadpool-plugin enhances Runnable. If Runnable extends 
ForkJoinTask, Runnable will be enhanced by apm-jdk-forkjoinpool-plugin first, 
and then will not be enhanced by apm-jdk-threadpool-plugin, so the subsequent 
plugin will not work properly.
   
   
![Image](https://github.com/user-attachments/assets/3bb25017-7af6-40a3-a262-0ee495b8140f)
   
   ### How to reproduce
   
   1. skywalking 9.3.0
   2. enable apm-jdk-threadpool-plugin、apm-jdk-forkjoinpool-plugin
   3. Print traceId in the logback.xml
   
   ```java
   import lombok.extern.slf4j.Slf4j;
   import org.springframework.web.bind.annotation.PutMapping;
   import org.springframework.web.bind.annotation.RequestMapping;
   import org.springframework.web.bind.annotation.RestController;
   
   import java.util.concurrent.CompletableFuture;
   import java.util.concurrent.ExecutorService;
   import java.util.concurrent.Executors;
   import java.util.concurrent.ForkJoinTask;
   
   @Slf4j
   @RestController
   @RequestMapping(value = "/test")
   public class TestController {
   
       ExecutorService executorService = Executors.newFixedThreadPool(10);
   
       @PutMapping("/test1")
       public void test() {
           executorService.submit(() -> {
               log.info("有traceId");
           });
           executorService.submit(new MyForkJoinTask(() -> {
               log.info("没有traceId: 继承ForkJoinTask");
           }));
           CompletableFuture.runAsync(() -> {
               log.info("没有traceId: 
CompletableFuture底层的AsyncRun继承ForkJoinTask");
           }, executorService);
       }
   
       public static class MyForkJoinTask extends ForkJoinTask<Void> implements 
Runnable {
           Runnable runnable;
   
           public MyForkJoinTask(Runnable runnable) {
               this.runnable = runnable;
           }
   
           @Override
           public void run() {runnable.run();}
   
           @Override
           public Void getRawResult() {return null;}
           @Override
           protected void setRawResult(Void value) {}
           @Override
           protected boolean exec() {return false;}
       }
   
   }
   
   ```
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [x] Yes I am willing to submit a pull request on my own!
   
   ### 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]

Reply via email to