Skip to content

Adds metric for merged MRs count using approval rules

Aishwarya Subramanian requested to merge 233765_approval_rule_merged_mrs into master

What does this MR do?

This MR adds metric to report the count of approval rules for merged merge requests.

Migration:

== 20201002175953 AddIndexForMergedMergeRequests: migrating ===================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:merge_requests, :id, {:where=>"state_id = 3", :name=>"idx_merge_requests_on_merged_state", :algorithm=>:concurrently})
   -> 0.0120s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- add_index(:merge_requests, :id, {:where=>"state_id = 3", :name=>"idx_merge_requests_on_merged_state", :algorithm=>:concurrently})
   -> 0.0059s
-- execute("RESET ALL")
   -> 0.0003s
== 20201002175953 AddIndexForMergedMergeRequests: migrated (0.0189s) ==========

Rollback:

== 20201002175953 AddIndexForMergedMergeRequests: reverting ===================
-- transaction_open?()
   -> 0.0000s
-- indexes(:merge_requests)
   -> 0.0124s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- remove_index(:merge_requests, {:algorithm=>:concurrently, :name=>"idx_merge_requests_on_merged_state"})
   -> 0.0032s
-- execute("RESET ALL")
   -> 0.0002s
== 20201002175953 AddIndexForMergedMergeRequests: reverted (0.0165s) ==========

Query:

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))
    AND "merge_requests"."id" BETWEEN 1 AND 100000

Execution plan:

https://explain.depesz.com/s/GFqC

Time taken:

Warm cache:

Time: 221.975 ms
  - planning: 0.935 ms
  - execution: 221.040 ms
    - I/O read: 0.000 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 256261 (~2.00 GiB) from the buffer pool
  - reads: 0 from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0

Cold cache:

Time: 576.633 ms
  - planning: 0.597 ms
  - execution: 576.036 ms
    - I/O read: 402.393 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 255833 (~2.00 GiB) from the buffer pool
  - reads: 428 (~3.30 MiB) from the OS file cache, including disk I/O
  - dirtied: 86 (~688.00 KiB)
  - writes: 0

Mentions #233765 (closed)

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Aishwarya Subramanian

Merge request reports