Deprecate and replace `counts.merged_merge_requests_using_approval_rules` metric
What does this MR do and why?
This MR:
- Deprecates
counts.merged_merge_requests_using_approval_rules
according with the metric lifecycle guidelines. - Adds a new metric
counts.merged_merge_requests_using_approval_rules_distinct
, which usesdistinct_count
using metric instrumentation classes.
@mbruemmer reported that there are some Service Ping payloads where counts.merged_merge_requests_using_approval_rules
is higher than counts.merge_requests
, which shouldn't be possible.
It turned out that counts.merged_merge_requests_using_approval_rules
uses count
instead of distinct_count
to calculate the metric, with MRs being counted multiple times if they have multiple approval roles, due to the join in the query. (See the original MR for details.)
The query is:
SELECT COUNT("merge_requests"."id") FROM "merge_requests" INNER JOIN "approval_merge_request_rules" ON "approval_merge_request_rules"."merge_request_id" = "merge_requests"."id" WHERE ("merge_requests"."state_id" IN (3))
https://explain.depesz.com/s/Khqf
And it should be:
SELECT COUNT(DISTINCT "merge_requests"."id") FROM "merge_requests" INNER JOIN "approval_merge_request_rules" ON "approval_merge_request_rules"."merge_request_id" = "merge_requests"."id" WHERE ("merge_requests"."state_id" IN (3))
https://explain.depesz.com/s/JmbiU
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.