Metrics: Add metrics for Flexible Scan Execution Policy Trigger Condition

Overview

Add simple usage metrics to track how many scan execution policies are using the new branch type options introduced in the Flexible Scan Execution Policy Trigger Condition feature, with project-level and group-level granularity to understand customer adoption.

Background

The feature introduces new branch types:

  • branch_type: target_default - Triggers scans on branches targeting the default branch
  • branch_type: target_protected - Triggers scans on branches targeting protected branches

We need to track adoption of these new options and ensure we have baseline metrics for existing branch types to understand how many customers are using each option.

Metrics to Implement

New Branch Type Usage Metrics (Real-time counters)

  • Count of projects using branch_type: target_default
  • Count of projects using branch_type: target_protected
  • Count of groups with projects using branch_type: target_default
  • Count of groups with projects using branch_type: target_protected

Existing Branch Type Usage Metrics (if not already tracked)

  • Count of projects using branch_type: default
  • Count of projects using branch_type: protected
  • Count of projects using branch_type: all
  • Count of projects using specific branch names
  • Count of projects using * (all branches)
  • Count of groups with projects using each existing branch type

Implementation Requirements

  • Real-time Counters: Update metrics immediately when policies are created/updated/deleted
  • Project-level Granularity: Track which projects are using each branch type option
  • Group-level Granularity: Track which groups have projects using each branch type option
  • Data Storage: Use existing GitLab metrics infrastructure
  • Reporting: Counters accessible in standard monitoring dashboards

Success Criteria

  • Real-time visibility into customer adoption of new target_default and target_protected options
  • Project and group level metrics to understand customer usage patterns
  • Baseline metrics for all branch type options to compare adoption rates
  • Clear understanding of how many customers are benefiting from the new feature
Edited by Alexander Turinske