You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/02/05 07:23:22 UTC

[GitHub] [skywalking-website] libinglong opened a new pull request #209: Propagate trace when using ThreadPoolExecutor

libinglong opened a new pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] libinglong commented on a change in pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
libinglong commented on a change in pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#discussion_r570936123



##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread

Review comment:
       What about adding a ThreadPoolExecutor tag?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] libinglong commented on a change in pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
libinglong commented on a change in pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#discussion_r572584452



##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04

Review comment:
       I remove the MyWrapper and process.png.
   There is also some little change to make the logic clear.
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] libinglong commented on a change in pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
libinglong commented on a change in pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#discussion_r571841368



##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class
+file format for classes that have been loaded previously. So skywalking can not always enhance the ThreadPoolExecutor 
+properly. However, we can apply advice to the ThreadPoolExecutor#execute method and wrap the Runnable param using our 
+own agent, then enhance the wrapper class by skywalking java agent. An advice do not change the layout of a class.
+
+Now we should decide how to do this. You can use the RunnableWrapper in the maven artifact 
+org.apache.skywalking:apm-toolkit-trace to wrap the param, but you will face another problem. This RunnableWrapper 
+has a plugin whose active condition is checking if there is @TraceCrossThread. Byte buddy in
+skywalking will use net.bytebuddy.pool.TypePool.Default.WithLazyResolution.LazyTypeDescription to find the annotations
+of a class. The LazyTypeDescription finds annotations by using a URLClassLoader with no urls if the classloader is
+null(bootstrap classloader). So it can not find the @TraceCrossThread class unless you change the LocationStrategy of
+skywalking java agent builder.
+
+In [this project](https://github.com/libinglong/skywalking-threadpool-agent), I write my own wrapper class, 

Review comment:
       1. added slf4j
   2. shaded byte buddy 
   > You are declaring, SkyWalking 7, which is not suitable, and where do you need SkyWalking agent?
   
   Now I have added a plugin which uses the SkyWalking 7




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] libinglong edited a comment on pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
libinglong edited a comment on pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#issuecomment-773933431


   
   
   
   > Several things I want to highlight
   > 
   > 1. You should use the words `propagate context` or `continue trace`. `Propagate trace` is strange.
   > 2. You are inviting people to use your project, then you need to make sure your project is under friendly Open Source License, please choose one.
   > 3. I noticed `com.lbl` in your package name, which company or entity do you actually mean? Do you already have the SGA in the license you are going to use?
   
   change propagate trace to propagate context
   change com.lbl to net.bird
   I have added the apache 2.0 license.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] libinglong commented on a change in pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
libinglong commented on a change in pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#discussion_r571549434



##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class

Review comment:
       > So skywalking can not always enhance the ThreadPoolExecutor properly.
   
   I think it's ambiguous to just using "enhance". We enhance, but fail to replace the loaded ThreadPoolExecutor. 
   The following sentence is more clear.
   So SkyWalking can not enhance the ThreadPoolExecutor successfully by retransforming when the ThreadPoolExecutor has been loaded.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] libinglong commented on a change in pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
libinglong commented on a change in pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#discussion_r571549434



##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class

Review comment:
       > So skywalking can not always enhance the ThreadPoolExecutor properly.
   
   I think it's ambiguous to just using "enhance". We enhance, but fail to replace the loaded ThreadPoolExecutor. 
   The following sentence is more clear.
   So skywalking can not enhance the ThreadPoolExecutor successfully by retransforming when the ThreadPoolExecutor has been loaded.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] wu-sheng commented on pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#issuecomment-775111271


   OK, get your point now. You are adding a plugin.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] wu-sheng commented on a change in pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#discussion_r571028029



##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class
+file format for classes that have been loaded previously. So skywalking can not always enhance the ThreadPoolExecutor 
+properly. However, we can apply advice to the ThreadPoolExecutor#execute method and wrap the Runnable param using our 
+own agent, then enhance the wrapper class by skywalking java agent. An advice do not change the layout of a class.
+
+Now we should decide how to do this. You can use the RunnableWrapper in the maven artifact 
+org.apache.skywalking:apm-toolkit-trace to wrap the param, but you will face another problem. This RunnableWrapper 
+has a plugin whose active condition is checking if there is @TraceCrossThread. Byte buddy in
+skywalking will use net.bytebuddy.pool.TypePool.Default.WithLazyResolution.LazyTypeDescription to find the annotations
+of a class. The LazyTypeDescription finds annotations by using a URLClassLoader with no urls if the classloader is
+null(bootstrap classloader). So it can not find the @TraceCrossThread class unless you change the LocationStrategy of
+skywalking java agent builder.
+
+In [this project](https://github.com/libinglong/skywalking-threadpool-agent), I write my own wrapper class, 
+and simply add a plugin with a name match condition.
+
+Finally, note you should add your own agent after the skywalking agent since the wrapper class should not be loaded before
+skywalking agent instrumentation have finished.

Review comment:
       Also, you could have release on your own repo, and guide users to your release page. It will be easier for the users.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] wu-sheng merged pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
wu-sheng merged pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] wu-sheng commented on a change in pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#discussion_r572010018



##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04

Review comment:
       2 things left.
   1. Are you sure, MyWrapper is a good name to deliver for the end user?
   2. If (1) is not problem, please update this to the current date, and no block from me.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] wu-sheng commented on a change in pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#discussion_r571846188



##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class
+file format for classes that have been loaded previously. So skywalking can not always enhance the ThreadPoolExecutor 
+properly. However, we can apply advice to the ThreadPoolExecutor#execute method and wrap the Runnable param using our 
+own agent, then enhance the wrapper class by skywalking java agent. An advice do not change the layout of a class.
+
+Now we should decide how to do this. You can use the RunnableWrapper in the maven artifact 
+org.apache.skywalking:apm-toolkit-trace to wrap the param, but you will face another problem. This RunnableWrapper 
+has a plugin whose active condition is checking if there is @TraceCrossThread. Byte buddy in
+skywalking will use net.bytebuddy.pool.TypePool.Default.WithLazyResolution.LazyTypeDescription to find the annotations
+of a class. The LazyTypeDescription finds annotations by using a URLClassLoader with no urls if the classloader is
+null(bootstrap classloader). So it can not find the @TraceCrossThread class unless you change the LocationStrategy of
+skywalking java agent builder.
+
+In [this project](https://github.com/libinglong/skywalking-threadpool-agent), I write my own wrapper class, 

Review comment:
       The official main repo has declared we are focusing on SkyWalking 8.x only, which has nearly no different at the agent side, please test with SkyWalking 8, and make them working well.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] wu-sheng commented on a change in pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#discussion_r570944349



##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread

Review comment:
       tag is only for widely used in multiple blogs.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] libinglong commented on pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
libinglong commented on pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#issuecomment-775041121


   > A key question, what is going to do with your `MyRunnableWrapper`? I am not following how your agent works with SkyWalking agent. Could you add a graph to this blog to show this clearly?
   
   OK.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] wu-sheng commented on pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#issuecomment-773851617


   Several things I want to highlight
   1. You should use the words `propagate context` or `continue trace`. `Propagate trace` is strange.
   2. You are inviting people to use your project, then you need to make sure your project is under friendly Open Source License, please choose one.
   3. I noticed `com.lbl` in your package name, which company or entity do you actually mean? Do you already have the SGA in the license you are going to use?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] libinglong commented on pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
libinglong commented on pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#issuecomment-773933431


   
   
   
   
   > Several things I want to highlight
   > 
   > 1. You should use the words `propagate context` or `continue trace`. `Propagate trace` is strange.
   > 2. You are inviting people to use your project, then you need to make sure your project is under friendly Open Source License, please choose one.
   > 3. I noticed `com.lbl` in your package name, which company or entity do you actually mean? Do you already have the SGA in the license you are going to use?
   
   changing from propagate trace to propagate context
   I have added the apache 2.0 license.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] wu-sheng commented on pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#issuecomment-775110115


   ![image](https://user-images.githubusercontent.com/5441976/107219216-b9f71000-6a4b-11eb-89b3-26109d7725d1.png)
   
   Is this part existing in SkyWalking already?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] wu-sheng commented on pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#issuecomment-773851617


   Several things I want to highlight
   1. You should use the words `propagate context` or `continue trace`. `Propagate trace` is strange.
   2. You are inviting people to use your project, then you need to make sure your project is under friendly Open Source License, please choose one.
   3. I noticed `com.lbl` in your package name, which company or entity do you actually mean? Do you already have the SGA in the license you are going to use?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] libinglong commented on a change in pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
libinglong commented on a change in pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#discussion_r571931852



##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class
+file format for classes that have been loaded previously. So skywalking can not always enhance the ThreadPoolExecutor 
+properly. However, we can apply advice to the ThreadPoolExecutor#execute method and wrap the Runnable param using our 
+own agent, then enhance the wrapper class by skywalking java agent. An advice do not change the layout of a class.
+
+Now we should decide how to do this. You can use the RunnableWrapper in the maven artifact 
+org.apache.skywalking:apm-toolkit-trace to wrap the param, but you will face another problem. This RunnableWrapper 
+has a plugin whose active condition is checking if there is @TraceCrossThread. Byte buddy in
+skywalking will use net.bytebuddy.pool.TypePool.Default.WithLazyResolution.LazyTypeDescription to find the annotations
+of a class. The LazyTypeDescription finds annotations by using a URLClassLoader with no urls if the classloader is
+null(bootstrap classloader). So it can not find the @TraceCrossThread class unless you change the LocationStrategy of
+skywalking java agent builder.
+
+In [this project](https://github.com/libinglong/skywalking-threadpool-agent), I write my own wrapper class, 

Review comment:
       OK. I will add a compatibility sheet.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-website] wu-sheng commented on a change in pull request #209: Propagate trace when using ThreadPoolExecutor

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #209:
URL: https://github.com/apache/skywalking-website/pull/209#discussion_r570921468



##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"

Review comment:
       ```suggestion
   which SkyWalking agent should not enhance"
   ```

##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special

Review comment:
       ```suggestion
   Skywalking java agent enhances a class by add a field and implement an interface. The ThreadPoolExecutor is a special
   ```

##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 

Review comment:
       All `skywalking` should be `SkyWalking`

##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class
+file format for classes that have been loaded previously. So skywalking can not always enhance the ThreadPoolExecutor 
+properly. However, we can apply advice to the ThreadPoolExecutor#execute method and wrap the Runnable param using our 
+own agent, then enhance the wrapper class by skywalking java agent. An advice do not change the layout of a class.
+
+Now we should decide how to do this. You can use the RunnableWrapper in the maven artifact 
+org.apache.skywalking:apm-toolkit-trace to wrap the param, but you will face another problem. This RunnableWrapper 

Review comment:
       ```suggestion
   org.apache.skywalking:apm-toolkit-trace to wrap the param, but you need to face another problem. This RunnableWrapper 
   ```

##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class
+file format for classes that have been loaded previously. So skywalking can not always enhance the ThreadPoolExecutor 
+properly. However, we can apply advice to the ThreadPoolExecutor#execute method and wrap the Runnable param using our 
+own agent, then enhance the wrapper class by skywalking java agent. An advice do not change the layout of a class.
+
+Now we should decide how to do this. You can use the RunnableWrapper in the maven artifact 
+org.apache.skywalking:apm-toolkit-trace to wrap the param, but you will face another problem. This RunnableWrapper 
+has a plugin whose active condition is checking if there is @TraceCrossThread. Byte buddy in
+skywalking will use net.bytebuddy.pool.TypePool.Default.WithLazyResolution.LazyTypeDescription to find the annotations
+of a class. The LazyTypeDescription finds annotations by using a URLClassLoader with no urls if the classloader is
+null(bootstrap classloader). So it can not find the @TraceCrossThread class unless you change the LocationStrategy of
+skywalking java agent builder.
+
+In [this project](https://github.com/libinglong/skywalking-threadpool-agent), I write my own wrapper class, 
+and simply add a plugin with a name match condition.
+
+Finally, note you should add your own agent after the skywalking agent since the wrapper class should not be loaded before
+skywalking agent instrumentation have finished.

Review comment:
       Recommend to share a `java -javaagent:` example here.

##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread

Review comment:
       ```suggestion
   ```

##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class

Review comment:
       I think this sentence is not correct. Bytebuddy, technically could enhance the class, but it is used inside agent core, and we are not sure the side-effect due to its widely used. 

##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class
+file format for classes that have been loaded previously. So skywalking can not always enhance the ThreadPoolExecutor 
+properly. However, we can apply advice to the ThreadPoolExecutor#execute method and wrap the Runnable param using our 
+own agent, then enhance the wrapper class by skywalking java agent. An advice do not change the layout of a class.
+
+Now we should decide how to do this. You can use the RunnableWrapper in the maven artifact 
+org.apache.skywalking:apm-toolkit-trace to wrap the param, but you will face another problem. This RunnableWrapper 
+has a plugin whose active condition is checking if there is @TraceCrossThread. Byte buddy in
+skywalking will use net.bytebuddy.pool.TypePool.Default.WithLazyResolution.LazyTypeDescription to find the annotations
+of a class. The LazyTypeDescription finds annotations by using a URLClassLoader with no urls if the classloader is
+null(bootstrap classloader). So it can not find the @TraceCrossThread class unless you change the LocationStrategy of
+skywalking java agent builder.
+
+In [this project](https://github.com/libinglong/skywalking-threadpool-agent), I write my own wrapper class, 

Review comment:
       Some issues of your codes
   1. System.out is used, https://github.com/libinglong/skywalking-threadpool-agent/blob/main/src/main/java/net/bird/listener/TransformListener.java#L43
   2. You are not shading anything, so, users could face bytebuddy conflict.
   3. You are declaring, SkyWalking 7, which is not suitable, and where do you need SkyWalking agent? https://github.com/libinglong/skywalking-threadpool-agent/blob/main/pom.xml#L14

##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class
+file format for classes that have been loaded previously. So skywalking can not always enhance the ThreadPoolExecutor 

Review comment:
       Not `can not`, is `should not`

##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class
+file format for classes that have been loaded previously. So skywalking can not always enhance the ThreadPoolExecutor 
+properly. However, we can apply advice to the ThreadPoolExecutor#execute method and wrap the Runnable param using our 
+own agent, then enhance the wrapper class by skywalking java agent. An advice do not change the layout of a class.
+
+Now we should decide how to do this. You can use the RunnableWrapper in the maven artifact 
+org.apache.skywalking:apm-toolkit-trace to wrap the param, but you will face another problem. This RunnableWrapper 
+has a plugin whose active condition is checking if there is @TraceCrossThread. Byte buddy in
+skywalking will use net.bytebuddy.pool.TypePool.Default.WithLazyResolution.LazyTypeDescription to find the annotations

Review comment:
       ```suggestion
   has a plugin whose active condition is checking if there is @TraceCrossThread. Agent core uses net.bytebuddy.pool.TypePool.Default.WithLazyResolution.LazyTypeDescription to find the annotations
   ```

##########
File path: content/blog/2021-02-04-skywalking-trace-threadpool/index.md
##########
@@ -0,0 +1,41 @@
+---
+title: "Apache SkyWalking: How to propagate context between threads when using ThreadPoolExecutor"
+date: 2021-02-04
+author: "Binglong Li"
+description: "This post introduces how to propagate context between threads when using ThreadPoolExecutor, 
+which skywalking agent can not enhance"
+tags:
+- Java
+- Agent
+- Tracing
+- thread
+---
+
+When using skywalking java agent, people usually propagate context easily. They even do not need to change the business 
+code. However, it becomes harder when you want to propagate context between threads when using ThreadPoolExecutor. 
+You can use the RunnableWrapper in the maven artifact org.apache.skywalking:apm-toolkit-trace. This way you must change 
+your code. The developer manager usually don't like this because there may be lots of projects, or lots of runnable code. 
+If they don't use skywalking some day, the code added will be superfluous and inelegant.
+
+Is there a way to propagate context without changing the business code? Yes. 
+
+Skywalking java agent enhances an instance by add a field and implement an interface. The ThreadPoolExecutor is a special
+class that is used widely. We even don't know when and where it is loaded. Most JVMs do not allow changes in the class
+file format for classes that have been loaded previously. So skywalking can not always enhance the ThreadPoolExecutor 
+properly. However, we can apply advice to the ThreadPoolExecutor#execute method and wrap the Runnable param using our 
+own agent, then enhance the wrapper class by skywalking java agent. An advice do not change the layout of a class.
+
+Now we should decide how to do this. You can use the RunnableWrapper in the maven artifact 
+org.apache.skywalking:apm-toolkit-trace to wrap the param, but you will face another problem. This RunnableWrapper 
+has a plugin whose active condition is checking if there is @TraceCrossThread. Byte buddy in
+skywalking will use net.bytebuddy.pool.TypePool.Default.WithLazyResolution.LazyTypeDescription to find the annotations
+of a class. The LazyTypeDescription finds annotations by using a URLClassLoader with no urls if the classloader is
+null(bootstrap classloader). So it can not find the @TraceCrossThread class unless you change the LocationStrategy of
+skywalking java agent builder.
+
+In [this project](https://github.com/libinglong/skywalking-threadpool-agent), I write my own wrapper class, 
+and simply add a plugin with a name match condition.
+
+Finally, note you should add your own agent after the skywalking agent since the wrapper class should not be loaded before

Review comment:
       ```suggestion
   Finally, note you should add this agent after the skywalking agent since the wrapper class should not be loaded before
   ```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org