heesung-sn commented on code in PR #21854:
URL: https://github.com/apache/pulsar/pull/21854#discussion_r1442351044


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/manager/UnloadManager.java:
##########
@@ -92,17 +153,35 @@ public void handleEvent(String serviceUnit, 
ServiceUnitStateData data, Throwable
             if (log.isDebugEnabled()) {
                 log.debug("Handling {} for service unit {} with exception.", 
data, serviceUnit, t);
             }
-            this.complete(serviceUnit, t);
+            complete(serviceUnit, t);
             return;
         }
+
+        if (log.isDebugEnabled()) {
+            log.debug("Handling {} for service unit {}", data, serviceUnit);
+        }
         ServiceUnitState state = ServiceUnitStateData.state(data);
         switch (state) {
-            case Free, Owned -> this.complete(serviceUnit, t);
-            default -> {
-                if (log.isDebugEnabled()) {
-                    log.debug("Handling {} for service unit {}", data, 
serviceUnit);
-                }
-            }
+            case Free, Owned -> complete(serviceUnit, t);
+            case Releasing -> recordReleaseLatency(serviceUnit, data);
+            case Assigning -> recordAssigningLatency(serviceUnit, data);
+        }
+    }
+
+    private void recordReleaseLatency(String serviceUnit, ServiceUnitStateData 
data) {
+        if (lookupServiceAddress.equals(data.sourceBroker())) {
+            releaseLatency.beginMeasurement(serviceUnit);
+            unloadLatency.beginMeasurement(serviceUnit);

Review Comment:
   Also, can we consider the following?
   
   The source broker collects unloading(end-2-end) latency
   start: when `Releasing` state is arrived
   end:  when the `Owned` state action is complete 
   
   The source broker collects release latency.
   start:  when `Releasing` state is arrived
   end:  when `Releasing` state action is complete.
   
   The destination broker collects assigining latency.
   start:  when the `Assigning` state is arrived
   end:  when the `Assigning` state action is complete 
   
   The source broker collects disconnect latency.
   start:  when the `Owned` state is arrived
   end:  when the `Owned` state action is complete 
   



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

Reply via email to