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 2022/04/06 10:11:44 UTC

[GitHub] [skywalking-java] Cool-Coding commented on pull request #140: Fix Grpc 1.x plugin's tracing problem (#8820)

Cool-Coding commented on PR #140:
URL: https://github.com/apache/skywalking-java/pull/140#issuecomment-1090094948

   
   
   
   > > The contextSnapshot and asyncSpan are all null at some situation.
   > 
   > In what cases this could be NULL? This kind of null check may avoid the issue, but we need to know why. Is this interceptor being called in some unexpected cases or any reason.
   
   @wu-sheng The value of contextSnapshot and asyncSpan is set in onReady method.
   
   `org.apache.skywalking.apm.plugin.grpc.v1.server.TracingServerCallListener`
   ```
       @Override
       public void onReady() {
           final AbstractSpan span = ContextManager.createEntrySpan(operation, contextCarrier);
           span.setComponent(ComponentsDefine.GRPC);
           span.setLayer(SpanLayer.RPC_FRAMEWORK);
           contextSnapshot = ContextManager.capture();
           asyncSpan = span.prepareForAsync();
           ContextManager.stopSpan(asyncSpan);
   
           super.onReady();
       }
   ```
   
   this onReady method is called by the `io.grpc.internal.ServerCallImpl.onReady` method
   ```
       @Override
       public void onReady() {
         if (call.cancelled) {
           return;
         }
         listener.onReady();
       }
   
       public void closed(Status status) {
         try {
           if (status.isOk()) {
             listener.onComplete();
           } else {
             call.cancelled = true;
             listener.onCancel();
           }
         } finally {
           // Cancel context after delivering RPC closure notification to allow the application to
           // clean up and update any state based on whether onComplete or onCancel was called.
           context.cancel(null);
         }
       }
   ```
   
   In debug mode, I found the value of `call.cancelled` variable is true. so the onReady is directly returned.  when the close method is invoked, Both of the value of contextSnapshot and asyncSpan is null.


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