Add merge_request branch exception bypass event
What does this MR do and why?
This MR adds a new event that is triggered whenever an MR is bypassed through the branch exceptions in security policies.
Local testing output
Monitored events or key path prefix: check_merge_request_branch_exceptions_bypass
RELEVANT METRICS
| Key Path | Monitored Events | Instrumentation Class | Initial Value | Current Value |
|---|---|---|---|---|
| redis_hll_counters.count_distinct_value_from_check_merge_request_branch_exceptions_bypass_monthly | check_merge_request_branch_exceptions_bypass | UniqueCountMetric | 0 | 1 |
| redis_hll_counters.count_distinct_value_from_check_merge_request_branch_exceptions_bypass_weekly | check_merge_request_branch_exceptions_bypass | UniqueCountMetric | 0 | 1 |
SNOWPLOW EVENTS
| Event Name | Collector Timestamp | Category | user_id | namespace_id | project_id | plan | Label | Property | Value | Extra |
|---|---|---|---|---|---|---|---|---|---|---|
| check_merge_request_branch_exceptions_bypass | 1756295968737 | MergeRequests::ReopenService | 249 | 63 | ultimate | 259 | {} |
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
- Create a group or a project
- Create MR approval policy with branch exceptions:
approval_policy:
- name: Branch Bypass
description: ''
enabled: true
rules:
- type: any_merge_request
branch_type: protected
commits: any
actions:
- type: require_approval
approvals_required: 1
role_approvers:
- maintainer
- developer
- type: send_bot_message
enabled: true
approval_settings:
block_branch_modification: true
prevent_pushing_and_force_pushing: true
prevent_approval_by_author: true
prevent_approval_by_commit_author: true
remove_approvals_with_new_commit: true
require_password_to_approve: false
fallback_behavior:
fail: closed
bypass_settings:
branches:
- source:
pattern: hotfix*
target:
name: main
- Execute the internal events monitor:
bundle exec rails runner scripts/internal_events/monitor.rb check_merge_request_branch_exceptions_bypass
- Create a project and create an MR with source branch
hotfix-123 - Verify that the metric is updated with the MR ID
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #549575 (closed)
Edited by Sashi Kumar Kumaresan