justxuewei commented on code in PR #2032:
URL: https://github.com/apache/dubbo-go/pull/2032#discussion_r967595918
##########
cluster/cluster/adaptivesvc/cluster_invoker.go:
##########
@@ -65,45 +64,20 @@ func (ivk *adaptiveServiceClusterInvoker) Invoke(ctx
context.Context, invocation
// select a node by the loadBalance
invoker := lb.Select(invokers, invocation)
-
+ _ =
metrics.SlidingWindowCounterMetrics.SetMethodMetrics(invoker.GetURL(),
invocation.MethodName(), metrics.Requests, 1)
// invoke
invocation.SetAttachment(constant.AdaptiveServiceEnabledKey,
constant.AdaptiveServiceIsEnabled)
+ startTime := time.Now().UnixNano()
result := invoker.Invoke(ctx, invocation)
-
+ rtt := time.Now().UnixNano() - startTime
// if the adaptive service encounters an error, DO NOT
// update the metrics.
if clsutils.IsAdaptiveServiceFailed(result.Error()) {
return result
- }
-
- // update metrics
- var remainingStr string
- remainingIface :=
result.Attachment(constant.AdaptiveServiceRemainingKey, nil)
- if remainingIface != nil {
- if str, strOK := remainingIface.(string); strOK {
- remainingStr = str
- } else if strArr, strArrOK := remainingIface.([]string);
strArrOK && len(strArr) > 0 {
- remainingStr = strArr[0]
- }
- }
- if remainingStr == "" {
- logger.Errorf("[adasvc cluster] The %s field type of value %v
should be string.",
- constant.AdaptiveServiceRemainingKey, remainingIface)
+ } else if errors.Is(result.Error(), context.DeadlineExceeded) {
Review Comment:
For the ddl execeeded error, it is worth wrapping a function, called
`IsDeadlineExceeded()`, in the `clsutils` package.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]