No-SilverBullet commented on code in PR #3013:
URL: https://github.com/apache/dubbo-go/pull/3013#discussion_r2331914360


##########
filter/active/filter.go:
##########
@@ -71,12 +71,23 @@ func (f *activeFilter) Invoke(ctx context.Context, invoker 
base.Invoker, inv bas
 // OnResponse update the active count base on the request result.
 func (f *activeFilter) OnResponse(ctx context.Context, result result.Result, 
invoker base.Invoker, inv base.Invocation) result.Result {
        startTime, err := 
strconv.ParseInt(inv.(*invocation.RPCInvocation).GetAttachmentWithDefaultValue(dubboInvokeStartTime,
 "0"), 10, 64)
+
+       defer func() {
+               if err != nil {
+                       // This err common is nil,when if not nil set a default 
elapsed value 1
+                       base.EndCount(invoker.GetURL(), inv.MethodName(), 1, 
false)
+                       return
+               }
+
+               elapsed := base.CurrentTimeMillis() - startTime
+               base.EndCount(invoker.GetURL(), inv.MethodName(), elapsed, 
result.Error() == nil)
+       }()
+
        if err != nil {
                result.SetError(err)
                logger.Errorf("parse dubbo_invoke_start_time to int64 failed")
                return result
        }
-       elapsed := base.CurrentTimeMillis() - startTime
-       base.EndCount(invoker.GetURL(), inv.MethodName(), elapsed, 
result.Error() == nil)
+

Review Comment:
   why use defer



-- 
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: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to