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/05/21 10:02:38 UTC

[GitHub] [skywalking] lujiajing1126 commented on pull request #6973: Fix ClassCast issue for RequestHolder/ResponseHolder

lujiajing1126 commented on pull request #6973:
URL: https://github.com/apache/skywalking/pull/6973#issuecomment-845838177


   I would summarize the idea,
   
   - `InvocableHandlerMethodInstrumentation` has switched to Plugin API v2. Thus we can take advantage of the performance improvement while sharing Reference between `InvokeInterceptor.beforeMethod` and  `InvokeInterceptor.afterMethod`
   
   After some investigation for the reactive scenario, the execution order of the `InvokeInterceptor` and `AbstractMethodInterceptor` is listed below,
   
   1. `InvokeInterceptor.beforeMethod`
   2. `InvokeInterceptor.afterMethod`
   3. `AbstractMethodInterceptor.beforeMethod`
   4. `AbstractMethodInterceptor.afterMethod`
   
   In order to record the real span of the async execution in the controller, we need to add a hook with the help of `Mono.doFinally`, which will be executed asynchronously.
   
   So we need to pass the span from `AbstractMethodInterceptor.afterMethod` to `InvokeInterceptor.afterMethod` which seems impossible. But we can do it with a Reference Container. 
   
   - In the past, the author used `ResponseHolder`, but due to the ClassLoader issue, it should be removed.
   - Now, I use a primitive array (`[]AbstractSpan`) as a slot.
   
   We follows the previous idea,
   
   - First, we put the slot in the RuntimeContext, as well as the MIC. So that we can access it in the InvokeInterceptor.afterMethod`
   - Then, we fetch the slot from `AbstractMethodInterceptor.afterMethod` and put the real `AbstractSpan` into it, after that we can safely remove the RuntimeContext.
   - Finally, when the lambda passed to the `Mono.doFinally` is executed, we can take it out from the MIC.


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