AlbumenJ commented on code in PR #13104:
URL: https://github.com/apache/dubbo/pull/13104#discussion_r1341303921


##########
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/data/BaseStatComposite.java:
##########
@@ -133,4 +133,14 @@ public ApplicationStatComposite 
getApplicationStatComposite() {
     public RtStatComposite getRtStatComposite() {
         return rtStatComposite;
     }
+
+    @Override
+    public boolean calSamplesChanged() {
+        // Should ensure that all the composite's samplesChanged have been 
compareAndSet, and cannot flip the `or` logic
+        boolean changed = applicationStatComposite.calSamplesChanged();
+        changed = rtStatComposite.calSamplesChanged() || changed;
+        changed = serviceStatComposite.calSamplesChanged() || changed;
+        changed = methodStatComposite.calSamplesChanged() || changed;
+        return changed;
+    }

Review Comment:
   `calSamplesChanged` before check `changed` can ensure that all the samples 
has been updated at once.
   For examle, if a composite contains A and B samples and these two samples 
are changed. If `calSamplesChanged` before check `changed` can update all the 
flags both in A and B. Thus, one time `refresh` can refresh all.



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

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to