qxo commented on issue #3065: Propose a API change : 
AbstractTracerContext#asyncStop and AsyncSpan#asyncFinish return boolean
URL: https://github.com/apache/skywalking/pull/3065#issuecomment-511099979
 
 
   Then what's wrong in 'TestAsyncStop' and how to using the api right?
   Any sample code ?
   
   This is current asyncStop : 
   ```
       @Override public void asyncStop(AsyncSpan span) {
           asyncSpanCounter.addAndGet(-1);
   
           if (checkFinishConditions()) {
               finish();
           }
       }
   
       private boolean checkFinishConditions() {
           if (isRunningInAsyncMode) {
               asyncFinishLock.lock();
           }
           try {
               if (activeSpanStack.isEmpty() && (!isRunningInAsyncMode || 
asyncSpanCounter.get() == 0)) {
                   return true;
               }
           } finally {
               if (isRunningInAsyncMode) {
                   asyncFinishLock.unlock();
               }
           }
           return false;
       }
   ```
   after prepareForAsync, isRunningInAsyncMode=true 
   and in asyncStop activeSpanStack must be empty then will invoke "finish"
   ony in "stopSpan" could make(pop) activeSpanStack  empty
   so before "asyncStop"  we must invoke "stopSpan" first ?
   
   要想在同一上下文调用asyncStop前必须先调用stopSpan?
   这是我实测的结果,不知是否和测试相符?
   
   代调用顺序如下调整可以发送数据到skywalking系统
   但总感觉如下调用有点问题
   ```
          span.prepareForAsync();
           Thread.sleep(3l);
           ContextManager.stopSpan(span);
           Thread.sleep(1l);
           span.asyncFinish();  
   ```
   
   另外关于API 健壮性:我主要指定的是目前实现一个span可以被多调次asyncStop, 
如能限制一个span只能调用一次stop(或只有第一次调用能有附加影响:能改程序状态),那就是基上能防止:“因plugin A的bug而导致之后的plugin 
B功能不正常" --  不过,这是另外一个问题

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