Skip to content

Deprecate and replace `counts.merged_merge_requests_using_approval_rules` metric

What does this MR do and why?

This MR:

@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.

Edited by Dan Jensen

Merge request reports