qxo commented on a change in pull request #3068: improve 
ContextManager.stopSpan performance: call ThreadLocal only once
URL: https://github.com/apache/skywalking/pull/3068#discussion_r303245146
 
 

 ##########
 File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
 ##########
 @@ -165,12 +166,20 @@ public static AbstractSpan activeSpan() {
         return get().activeSpan();
     }
 
+    /**
+    * Plese use `ContextManager.stopSpan(span)` if could, it's can "fail-fast"
 
 Review comment:
    This comment is target another design issue:
   use `ContextManager.stopSpan(span)` better than 'ContextManager.stopSpan()`
   it's found program error 
   ie:
   ```
           final AbstractSpan span10 = ContextManager.createLocalSpan("op10");
           //work10
           final AbstractSpan span11 = ContextManager.createLocalSpan("op11");
         //work11
           ContextManager.stopSpan(span10); 
         //...
           ContextManager.stopSpan(span11);
   ```
   if  'ContextManager.stopSpan(span10);' is plugin bug, should not call stop 
in this point
   then will throw: ` java.lang.IllegalStateException: Stopping the unexpected`
   I call it's a Fail-fast design
   
   If just call `ContextManager.stopSpan()` will hide the bug in the plugin
   
   不知这样英文表达是否清楚,我中文再说了一下吧:
    `ContextManager.stopSpan()` 是容易隐藏编程错误 
   而明确调用 'ContextManager.stopSpan(span10);' 如顺序不对就会直接报错-- Fail-fast
   
   

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