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?
   
   leader collects unloading(end-2-end) latency (global unloding latency 
metrics)
   start:  when the unloading decision is made
   end:  when the unloading is complete (when inFlightUnloadRequest is complete 
upon the `Owned` state)
   
   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