qxo edited a comment on issue #3065: Propose a API change : 
AbstractTracerContext#asyncStop and AsyncSpan#asyncFinish return boolean
URL: https://github.com/apache/skywalking/pull/3065#issuecomment-511087746
 
 
   @wu-sheng 
   prepareAsync first, then asyncFinish at somewhere else  not work:
   case checkFinishConditions() is false(activeSpanStack is not empty)
   ```
   import org.apache.skywalking.apm.agent.core.conf.RemoteDownstreamConfig;
   import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
   import org.apache.skywalking.apm.agent.core.context.ContextManager;
   import org.apache.skywalking.apm.agent.core.context.tag.Tags;
   import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
   import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
   import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil;
   import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
   
   public class TestAsyncStop {
   
       public static void main(String[] args) throws Exception {
           long start = System.currentTimeMillis();
           // wait for skywalking agent ready
           while (true) {
               Thread.sleep(200l);
               if (RemoteDownstreamConfig.Agent.SERVICE_ID != 
DictionaryUtil.nullValue()
                       && RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID != 
DictionaryUtil.nullValue()) {
                   System.out.println("skywalking is ready:" + 
(System.currentTimeMillis() - start) + " ms");
                   break;
               }
           }
   
           ContextCarrier contextCarrier = new ContextCarrier();
           final String opName = "/abc123";
           AbstractSpan span = ContextManager.createEntrySpan(opName, 
contextCarrier);
   
           span.setComponent(ComponentsDefine.VERTX);
           SpanLayer.asHttp(span);
   
           Tags.HTTP.METHOD.set(span, "GET");
           Tags.URL.set(span, opName);
           span.prepareForAsync();
           Thread.sleep(1l);
           span.asyncFinish();
           try {// wait for skywalking to finish
               Thread.sleep(200l);
           } catch (InterruptedException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
           }
       }
    }
   ```
   please fix the code:)

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to