RongtongJin commented on code in PR #10514:
URL: https://github.com/apache/rocketmq/pull/10514#discussion_r3449480835


##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java:
##########
@@ -635,12 +681,17 @@ public void setSerializeTypeCurrentRPC(SerializeType 
serializeTypeCurrentRPC) {
         this.serializeTypeCurrentRPC = serializeTypeCurrentRPC;
     }
 
-    public Stopwatch getProcessTimer() {
-        return processTimer;
+    public long processTimerElapsedMs() {

Review Comment:
   `processTimerNanos` defaults to `0`, so any command that reaches metrics 
without going through `setProcessTimerNanos()` will report roughly JVM uptime 
instead of an unknown/zero request latency. That can happen in tests or any 
future path that constructs a `RemotingCommand` directly. Consider initializing 
the field when the command is created, or guarding `processTimerNanos == 0` in 
`processTimerElapsedMs()` and adding a small regression test for the unset case.



##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java:
##########
@@ -635,12 +681,17 @@ public void setSerializeTypeCurrentRPC(SerializeType 
serializeTypeCurrentRPC) {
         this.serializeTypeCurrentRPC = serializeTypeCurrentRPC;
     }
 
-    public Stopwatch getProcessTimer() {
-        return processTimer;
+    public long processTimerElapsedMs() {
+        return (System.nanoTime() - processTimerNanos) / 1_000_000;
+    }
+
+    @Deprecated
+    public com.google.common.base.Stopwatch getProcessTimer() {
+        return com.google.common.base.Stopwatch.createStarted();

Review Comment:
   Keeping this deprecated method helps source compatibility, but returning a 
newly-started `Stopwatch` no longer represents the request processing timer. 
Any downstream caller that was not updated will silently observe near-zero 
latency instead of the real elapsed time. If this method stays for 
compatibility, please either back it from `processTimerNanos`/document the 
semantic break explicitly, or make remaining usage fail visibly rather than 
producing misleading metrics.



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