rdhabalia closed pull request #2916: Fix zk latency metrics collector
URL: https://github.com/apache/pulsar/pull/2916
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/zookeeper/aspectj/ClientCnxnAspect.java
 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/zookeeper/aspectj/ClientCnxnAspect.java
index ca78018e2b..33bd11c5b1 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/zookeeper/aspectj/ClientCnxnAspect.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/zookeeper/aspectj/ClientCnxnAspect.java
@@ -21,6 +21,7 @@
 import java.lang.reflect.Field;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
 
 import com.google.common.collect.Lists;
 import org.apache.bookkeeper.util.MathUtils;
@@ -83,16 +84,16 @@ public void run() {
     }
 
     private void processEvent(ProceedingJoinPoint joinPoint) {
-        long startTimeMs = getStartTime(joinPoint.getArgs()[0]);
-        if (startTimeMs == -1) {
+        long startTimeNano = getStartTime(joinPoint.getArgs()[0]);
+        if (startTimeNano == -1) {
             // couldn't find start time
             return;
         }
         Record request = getEventType(joinPoint.getArgs()[0]);
 
         if (request != null) {
-            long timeElapsed = (MathUtils.now() - startTimeMs);
-            notifyListeners(checkType(request), timeElapsed);
+            long timeElapsed = (MathUtils.nowInNano() - startTimeNano);
+            notifyListeners(checkType(request), 
TimeUnit.NANOSECONDS.toMicros(timeElapsed));
         }
     }
 
@@ -156,7 +157,7 @@ private long getStartTime(Object packet) {
                 if (zooworker != null
                         && 
zooworker.getClass().getName().equals("org.apache.bookkeeper.zookeeper.ZooWorker"))
 {
                     Field timeField = 
Class.forName("org.apache.bookkeeper.zookeeper.ZooWorker")
-                            .getDeclaredField("startTimeMs");
+                            .getDeclaredField("startTimeNanos");
                     timeField.setAccessible(true);
                     long startTime = (long) timeField.get(zooworker);
                     return startTime;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to