wu-sheng commented on a change in pull request #6232:
URL: https://github.com/apache/skywalking/pull/6232#discussion_r560607103



##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/sampling/SamplingService.java
##########
@@ -90,9 +88,9 @@ public void shutdown() {
      * @return true, if sampling mechanism is on, and getDefault the sampling 
factor successfully.
      */
     public boolean trySampling(String operationName) {
-        if (on) {
+        if (samplingRateWatcher.getSamplingRate() > 0) {

Review comment:
       Two `samplingRateWatcher.getSamplingRate() > 0`(s) in `#trySampling` and 
`#forceSampled` are changing the previous logic.
   We don't need to `#getSamplingRate` every time, it costs resource. 
`#shouldSample` method needs to be added, and you should only change the 
boolean result when change happens.




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


Reply via email to