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 2020/05/29 09:22:59 UTC

[GitHub] [skywalking] BFergerson opened a new issue #4841: Customize enhance plugin extensions

BFergerson opened a new issue #4841:
URL: https://github.com/apache/skywalking/issues/4841


   - Why do you submit this issue?
   - [x] Question or discussion
   
   ___
   ### Question
   
   I would like to extend the `customize-enhance-plugin` and I would like to know if these changes are of any interest to anyone.
   
   ### Ability to wildcard methods
   
   Instead of choosing every method, it would be nice to be able to say all the methods in a certain class are of interest, like so:
   ```xml
   <enhanced>
       <class class_name="test.org.apache.skywalking.apm.testcase.customize.service.TestService1">
           <method method="*" static="true"></method>
           <method method="staticMethod(java.lang.String,int.class,java.util.Map,java.util.List,[Ljava.lang.Object;)"
                   operation_name="/is_static_method_args" static="true">
               <operation_name_suffix>arg[0]</operation_name_suffix>
               <operation_name_suffix>arg[1]</operation_name_suffix>
               <operation_name_suffix>arg[3].[0]</operation_name_suffix>
               <tag key="tag_1">arg[2].['k1']</tag>
               <tag key="tag_2">arg[4].[1]</tag>
               <log key="log_1">arg[4].[2]</log>
           </method>
       </class>
   </enhanced>
   ```
   
   Here I've said that every static method in `TestService1` should be traced but that the specific method `staticMethod(java.lang.String,int.class,java.util.Map,java.util.List,[Ljava.lang.Object;)` should also be traced with additional data.
   
   Given that getter/setter methods would also be picked up with this approach I would also propose that this wildcard approach by default does not pick those up unless specified via `includeSetters="true"`/`includeGetters="true"`.
   
   ### Ability to wildcard classes
   
   Just like the wildcarding methods, I think it would be beneficial to say that all the classes in a certain package (or sub-packages) are of interest to tracing. Example:
   ```xml
   <enhanced>
       <class class_name="test.org.apache.skywalking.apm.testcase.customize.service.*">
           <method method="*" static="true"></method>
           <method method="staticMethod(java.lang.String,int.class,java.util.Map,java.util.List,[Ljava.lang.Object;)"
                   operation_name="/is_static_method_args" static="true">
               <operation_name_suffix>arg[0]</operation_name_suffix>
               <operation_name_suffix>arg[1]</operation_name_suffix>
               <operation_name_suffix>arg[3].[0]</operation_name_suffix>
               <tag key="tag_1">arg[2].['k1']</tag>
               <tag key="tag_2">arg[4].[1]</tag>
               <log key="log_1">arg[4].[2]</log>
           </method>
       </class>
   </enhanced>
   ```
   
   Here I've said any classes in `test.org.apache.skywalking.apm.testcase.customize.service` and sub-packages should be traced. In those classes all the static methods should be traced (except getter/setter methods) and that any method in any class within those that match the signature `staticMethod(java.lang.String,int.class,java.util.Map,java.util.List,[Ljava.lang.Object;)` should also be traced but with additional settings applied.
   
   ### Ability to choose span type
   
   Instead of just creating local span types I think it would also be beneficial if the span type could be chosen via this plugin. This will increase the ability to programmatically produce tracing configurations for SkyWalking to use. With my project ([Source++](https://github.com/sourceplusplus/assistant)), my plan is to expose a SkyWalking UI to developers inside their IDE. Instead of creating a plugin for SkyWalking or using `@Trace` they could simply hit a keyboard shortcut and a UI would pop up asking them how they would like to trace it, what type of span it is, and what data should be logged/collected. This would then be used in the creation of `customize_enhance.xml` which would be automatically generated whenever they launch programs via there IDE.
   
   I can also envision the scenario where a solution like this could be used in the creation of more SkyWalking plugins. It can sometimes be difficult to create a SkyWalking plugin across many versions of frameworks (especially async frameworks). With the ability to programmatically chose what types of spans to create it would be much easier to simply choose a couple of methods and then see what that results in and then choose more/other methods and reboot to see if that fixes thing. They would then have a `customize_enhance.xml` file which would tell them the classes/methods/span types they would need to use to make a physical plugin (via skywalking-plugin.def).
   
   I think it would look something like:
   ```
   <method method="acceptUserRequest(com.example.RequestData)" span_type="entry"></method>
   <method method="sendUserResponse(com.example.ResponseData)" span_type="exit"></method>
   ```
   This would mean that method(s) with the signature `acceptUserRequest(com.example.RequestData)` should create entry spans and the method(s) with the signature `sendUserResponse(com.example.ResponseData)` should create xit spans.
   
   I understand that this isn't currently enough information to correctly add the necessary `ContextCarrier` to those methods but `customize-enhance-plugin` already has a mechanism for logging/tagging user data (e.g. `arg[4].[2]`), so my thought was that there would need to be a way to do that to inject and extract the `ContextCarrier`. I haven't thought too much about this yet so I would appreciate any input.
   
   ----
   
   I've already implemented the ability to wildcard methods, classes, and packages but I'm curious if any of these features (included the ability to specify span type) are something that SkyWalking would like. If not I'll implement these features as an internal custom 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] wu-sheng commented on issue #4841: Customize enhance plugin extensions

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #4841:
URL: https://github.com/apache/skywalking/issues/4841#issuecomment-636560122


   ping @zhaoyuguang due to you write this plugin at the first place.


----------------------------------------------------------------
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] wu-sheng commented on issue #4841: Customize enhance plugin extensions

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #4841:
URL: https://github.com/apache/skywalking/issues/4841#issuecomment-692146971


   Thanks for your clarification. Close for now. Let me know if you have blocks when you are doing the IDE integration.


----------------------------------------------------------------
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] wu-sheng commented on issue #4841: Customize enhance plugin extensions

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #4841:
URL: https://github.com/apache/skywalking/issues/4841#issuecomment-636558882


   Thanks @BFergerson to bring this up.
   
   Wildcard seems good to add. 
   I want to talk more about the `span type`, a very important thing about it is, `span type` relates to the topology, so once it is set, but lack of ref(ContextCarrier from header) or peer(exit span specifically) may cause backend error. We need to be very careful. Also, if we don't add ref/peer to entry/exit span, it seems entry/exit span is pointless, why do you want to add this?


----------------------------------------------------------------
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] BFergerson commented on issue #4841: Customize enhance plugin extensions

Posted by GitBox <gi...@apache.org>.
BFergerson commented on issue #4841:
URL: https://github.com/apache/skywalking/issues/4841#issuecomment-692142519


   @wu-sheng, I can push my code on the wildcard method/package but I still have work to do for specifying the entry/exit span type. I was not aware of the issues involved with not specifying ref/peer.
   
   You don't need to keep this issue open. I mainly just wanted to bounce some ideas off you guys if you thought the idea of being able to create a plugin via a UI which generated `customize_enhance.xml` was of any interest or not. I plan on adding the ability to do that with the SourceMarker project.


----------------------------------------------------------------
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] wu-sheng closed issue #4841: Customize enhance plugin extensions

Posted by GitBox <gi...@apache.org>.
wu-sheng closed issue #4841:
URL: https://github.com/apache/skywalking/issues/4841


   


----------------------------------------------------------------
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] wu-sheng commented on issue #4841: Customize enhance plugin extensions

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #4841:
URL: https://github.com/apache/skywalking/issues/4841#issuecomment-692132873


   @BFergerson Any progress about this? 


----------------------------------------------------------------
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] zhaoyuguang commented on issue #4841: Customize enhance plugin extensions

Posted by GitBox <gi...@apache.org>.
zhaoyuguang commented on issue #4841:
URL: https://github.com/apache/skywalking/issues/4841#issuecomment-636594829


   That sounds good!
   
   it would probably be great in the following scenarios if implemented. Async frameworks, or we don't know much about the underlying framework or the framework within our own organization. You can quickly complete the plug-in.
   As for `ref` and `peer`, I think we can make a contract with the user to expose some appropriate API, let them fill in the peer in `exit span`, and tell `SkyWalking`  how get `ref`. So for synchronized threads, there are a few Suggestions for exitspan and entryspan:
   
   `Exit span` needs to add an entry point for input peer and return the serialized data to the user contextCarrier.
   `Entry span` needs to add places where the specified user fills in the contextCarrier serialized data, and be careful with the batch framework.
   
   


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