zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] jhuan31 commented on a change in pull request #856: ZOOKEEPER-3319: Add metrics for follower and observer
Date Mon, 18 Mar 2019 21:05:55 GMT
jhuan31 commented on a change in pull request #856: ZOOKEEPER-3319: Add metrics for follower
and observer
URL: https://github.com/apache/zookeeper/pull/856#discussion_r266641485
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/Request.java
 ##########
 @@ -305,4 +305,25 @@ public void setException(KeeperException e) {
     public KeeperException getException() {
         return e;
     }
+
+    public void logLatency(ServerMetrics metric, String key, long currentTime) {
+        if (hdr != null) {
+            /* Request header is created by leader. If there is clock drift
+             * latency might be negative. Headers use wall time, not
+             * CLOCK_MONOTONIC.
+             */
+            long latency = currentTime - hdr.getTime();
+            if (latency > 0) {
+                if (key != null) {
+                    metric.add(key, latency);
 
 Review comment:
   If the metric is of type Set, then we need the key. If not, then key should be null.  For
example, ACK_LATENCY is of type AvgMinMaxPercentileCounterSet, meaning we record the latency
for each server and the server_id is the key. 
   
   Maybe it's better to overload logLatency(), one with key parameter, one w/o parameter,
instead of checking null. What do you think?
   
   Also I have been thinking how to represent Set metrics using the new APIs. My intuition
is that context should be the answer but we probably need a couple more APIs.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message