AsperforMias opened a new pull request, #3861:
URL: https://github.com/apache/dubbo-go/pull/3861

   ### Description
   Part of #3857
   
   Each failover attempt goes through the reference filter chain and is 
recorded as a separate consumer request, so a retried call looks like extra 
traffic plus failures, and retries cannot be measured.
   
   This PR adds `dubbo_consumer_retries_total`, labeled like the other consumer 
metrics:
   
   - The failover cluster invoker marks every attempt after the first as a 
retry of its invocation, in the context it passes to that attempt 
(`base.WithRetryAttempt`, read with `base.IsRetryAttempt`). The mark is scoped 
to the attempt, so it does not outlive the call or leak between concurrent 
group calls. Attempts of the same invocation in a group failover inside a 
retried multi-group failover inherit it, while another RPC started with that 
context, such as a call made by a local provider or a filter, has its own 
invocation and is not counted as a retry. The generic filter, which forwards a 
translated invocation, hands the mark over to it (`base.TransferRetryAttempt`). 
The cluster does not depend on the metrics packages.
   - The metrics filter reads the mark (`rpc.NewBeforeInvokeEventWithContext`; 
`NewBeforeInvokeEvent` keeps its signature), and the collector counts the retry 
when the attempt completes, together with `requests_total`. A reference that 
excludes the metrics filter therefore records neither, and an attempt that is 
never confirmed records neither.
   - The counter is exported at 0 with the first `requests_total` of a consumer 
series, so `dubbo_consumer_requests_total - dubbo_consumer_retries_total` (the 
logical calls) is defined for consumers that never retried.
   - Both recording paths count it; it has no sliding-window variant.
   
   Counting failures that happen before any attempt (for example no provider 
available after routing), also listed in #3857, is not part of this PR.
   
   Verified with a consumer calling two addresses, one without a listener: 20 
calls succeeded, with `requests_total` = 30, `requests_failed_total` = 10 and 
`retries_total` = 10, so `requests_total - retries_total` = 20.
   
   In Prometheus, with a consumer calling about 10 times per second and one of 
its two addresses down, the logical calls stay at the call rate while requests 
and retries rise with the failed attempts:
   
   ![consumer requests, retries and logical 
calls](https://raw.githubusercontent.com/AsperforMias/dubbo-go/obs-gaps-screenshots/retries.png)
   
   The new tests fail if failover does not mark retries or if the counter is 
not exported before the first retry; they also cover a failover nested in a 
retried failover, an RPC started with a retried attempt's context, and both 
generic call forms.
   
   Not stacked on any PR. It has small textual conflicts with the PR for #3858 
(aggregation settings) in `metrics/rpc/metric_set.go`; I will rebase whichever 
lands second.
   
   ### Checklist
   - [x] I confirm the target branch is `develop`
   - [x] I have run `make fmt` to format my code
   - [x] I have run `make test` to run local tests
   - [x] I have added tests that prove my fix is effective or that my feature 
works
   


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

  • [PR] feat(metrics): cou... AsperforMias (via GitHub) via notifications

Reply via email to