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/06/30 02:21:10 UTC

[GitHub] [skywalking] xuanyu66 commented on issue #7200: ExitSpan can't log exception when asyncFinish

xuanyu66 commented on issue #7200:
URL: https://github.com/apache/skywalking/issues/7200#issuecomment-871047060


   We find thrift async call can't log exception.
   ```
   public class TAsyncMethodCallInterceptor implements InstanceConstructorInterceptor, InstanceMethodsAroundInterceptor {
       private String remotePeer = "UNKNOWN";
   
       @Override
       public void onConstruct(EnhancedInstance objInst,
                               Object[] allArguments) throws NoSuchFieldException, IllegalAccessException {
           ReflectionUtils.setValue(TAsyncMethodCall.class, objInst, "callback", new AsyncMethodCallback<Object>() {
               final AsyncMethodCallback<Object> callback = (AsyncMethodCallback) allArguments[3];
   
               @Override
               public void onComplete(final Object response) {
                   try {
                       AsyncSpan span = (AsyncSpan) objInst.getSkyWalkingDynamicField();
                       span.asyncFinish();
                   } finally {
                       callback.onComplete(response);
                   }
               }
   
               @Override
               public void onError(final Exception exception) {
                   try {
                       AsyncSpan span = (AsyncSpan) objInst.getSkyWalkingDynamicField();
                       span.asyncFinish().log(exception);
                   } finally {
                       callback.onError(exception);
                   }
               }
           });
           if (allArguments[2] instanceof EnhancedInstance) {
               remotePeer = (String) ((EnhancedInstance) allArguments[2]).getSkyWalkingDynamicField();
           }
       }
   
   ```


-- 
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: notifications-unsubscribe@skywalking.apache.org

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