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

   ### Description
   Fixes #3858
   
   `metrics.aggregation.enabled`, `bucket-num` and `time-window-seconds` had no 
effect: the sliding-window metrics (QPS, `*_aggregate`, aggregated RT, RT 
quantiles) were always registered, with the default window.
   
   - `enabled` now controls these metrics on both recording paths 
(collection-time gauges and the record-time path for custom registries). The 
cumulative counters and RT metrics are not affected.
   - **Its default changes from `false` to `true`.** This keeps exporting the 
metrics that were in fact always exported, including the ones the Dubbo Admin 
dashboards query (`dubbo_consumer_rt_avg_milliseconds_aggregate`, `*_p95` / 
`*_p99`, min/max RT). Honoring the old `false` default would have emptied those 
panels for every application that does not set it. `WithAggregationDisabled()` 
turns them off from code.
   - `bucket-num` and `time-window-seconds` now set the window of these 
metrics. `NewQpsMetricVec`, `NewAggregateCounterVec` and `NewQuantileMetricVec` 
take an optional window (`metrics.WithWindow`), so existing calls compile 
unchanged.
   - `bucket-num` is capped at `time-window-seconds`, so each bucket covers at 
least one second; more buckets than milliseconds would otherwise make the 
window divide by zero.
   - QPS divides by the lived window time in fractional seconds. It used to 
truncate it to whole seconds, which made QPS 0 or too high when a bucket is not 
a whole number of seconds. The default window (12-second buckets) is not 
affected.
   
   Verified with a provider and `/metrics`:
   
   - default: `*_aggregate`, `qps_total` and `*_p99` exported as before
   - `WithAggregationDisabled()`: only the cumulative metrics are exported
   - `bucket-num=1`, `time-window-seconds=2`: `*_aggregate` and `qps_total` 
drop to 0 three seconds after the calls, while `requests_total` keeps its value
   
   In Prometheus, a provider with `bucket-num: 3` and `time-window-seconds: 30` 
called for 60 seconds: `requests_total_aggregate` drops to 0 within 30 seconds 
after the calls stop, while `requests_total` keeps its value. On develop the 
aggregate keeps the default 120-second window.
   
   ![requests_total and requests_total_aggregate with a 30-second 
window](https://raw.githubusercontent.com/AsperforMias/dubbo-go/obs-gaps-screenshots/aggregation-window.png)
   
   The new tests fail if `enabled` is ignored or the configured window is 
replaced by the default. `TestAggregationWindowIsConfigurable` waits 2.5s for a 
1-second window to expire.
   
   Not stacked on any PR. It has a small textual conflict with the PR for #3857 
(retry metrics) in `metrics/rpc/metric_set.go`, where both change the consumer 
metric initialization; 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] fix(metr... AsperforMias (via GitHub) via notifications
    • Re: [PR]... sonarqubecloud[bot] (via GitHub) via notifications
    • Re: [PR]... github-advanced-security[bot] (via GitHub) via notifications
    • Re: [PR]... codecov-commenter (via GitHub) via notifications
    • Re: [PR]... sonarqubecloud[bot] (via GitHub) via notifications
    • Re: [PR]... sonarqubecloud[bot] (via GitHub) via notifications

Reply via email to