daimingzhi opened a new issue #7440:
URL: https://github.com/apache/skywalking/issues/7440


   - Discussion : multi-interceptors supporting in SkyWalking
   
   As I have mentioned in 
[https://github.com/apache/skywalking/issues/6932#issuecomment-895825310](url)。
   
   For extensibility of SkyWaling, we should support multi-interceptors。
   
   I have two ways of doing this:
   
   # the first one
   We can construct multiple ClassFileTransformer instances. In each 
ClassFileTransformer, there will only be one pluginDefine for each class.To do 
this, we should group the plugindefine,and we will construct a 
ClassFileTransformer instance for each group.
   The code might look something like this
   
   ```java
   List<PluginFinder> pluginFinders = groupByPluginDefine();
   for (PluginFinder finder : pluginFinders) {
       agentBuilder.type(finder.buildMatch())
           .transform(new Transformer(finder))
           .with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
           .with(new Listener())
           .installOn(instrumentation);
   }
   ```
   What the method named groupByPluginDefine method does is group the 
pluginDefine, and promise only one pluginDefine for each class per group.
   
   # the second one
   I have debugged code, and found the reason is every time a class is 
enhanced, it will delegate the original method to a new InstMethodsInter 
instance. So, the previous is overridden.
    
![image-20210811135321186](https://gitee.com/easy4coding/blogImage/raw/master/image/image-20210811135321186.png)
   
   To solve it, maybe we can cache the interceptor and merge them.
   
   Finally, I also looked for new apis in ByteBuddy as an alternative to 
`MethodDelegation`. but,I am newer for it.This will be a long time.
   This is my whole idea.I hope some seniors can give me some advice. Thanks.
   


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