Github user karanmehta93 commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/307#discussion_r187815063
  
    --- Diff: src/java/main/org/apache/zookeeper/server/ServerStats.java ---
    @@ -148,9 +174,46 @@ synchronized public void resetRequestCounters(){
             packetsReceived = 0;
             packetsSent = 0;
         }
    +    synchronized public void resetNumRequestsAboveThresholdTime() {
    +        numRequestsAboveThresholdTime = 0;
    +    }
         synchronized public void reset() {
             resetLatency();
             resetRequestCounters();
    +        resetNumRequestsAboveThresholdTime();
    +    }
    +
    +    public void checkLatency(final ZooKeeperServer zks, Request request) {
    +        long requestLatency = Time.currentElapsedTime() - 
request.createTime;
    +        boolean enabledAndAboveThreshold = (requestWarnThresholdMs == 0) ||
    +                (requestWarnThresholdMs > -1 && requestLatency > 
requestWarnThresholdMs);
    --- End diff --
    
    The reason for explicit check of condition `requestWarnThresholdMs == 0` is 
two fold. One is for debugging scenarios where you want to log time for each 
request and for test purposes. There were cases when request would finish in 
less than 1 ms and hence the timer would show `requestLatency` as 0. It is 
added to make my test `HighLatencyRequestLoggingTest` not flaky. What do you 
think?


---

Reply via email to