Add internal event tracking ci_build_minutes
What does this MR do and why?
Adds internal event tracking to collect sum of total monthly ci build minutes
- Tracks events when builds > 0 minutes complete and
UpdateBuildMinutesServiceis executed. - Metric added for total monthly ci build minutes
- Metric added for total monthly ci build minutes filtered on
runner_type == "group_type" - Metric added for total monthly ci build minutes filtered on
runner_type == "instance_type" - Metric added for total monthly ci build minutes filtered on
runner_type == "project_type" - event records:
- build's duration in minutes passed as the
value - the runner_type used to process the build as
label
- build's duration in minutes passed as the
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
NOTE: In the following screenshots and in the events that are sent to snowplow - value === ci_build_minutes (aka build duration in minutes rounded to 2 decimals) & label === the type of runner that processed the build (ie instance, project, group)
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
This is a backend internal event tracker. To test this locally the easiest way is to use the basic event monitor and trigger the action that tracks the event.
- **To start an internal event monitor: **
From within the gitlab repository run
rails runner scripts/internal_events/monitor.rb track_ci_build_minutes_with_runner_type - From your local host - run a pipeline in one of your projects (for best results, set a sleep for several minutes in the middle of a few of your stages)
- Observe the event monitor update as each build completes
Alternative local testing:
- From a terminal --> run
rails runner scripts/internal_events/monitor.rb track_ci_build_minutes_with_runner_type - In another tab or terminal windwo --> run a rails console
bundle exec rails console - trigger a series of events from the rails console and observe the internal event monitor updating
Gitlab::InternalEvents.track_event("track_ci_build_minutes_with_runner_type", additional_properties: {label: "group_type", value: 5.73})
Gitlab::InternalEvents.track_event("track_ci_build_minutes_with_runner_type", additional_properties: {label: "project_type", value: 0.87})
Gitlab::InternalEvents.track_event("track_ci_build_minutes_with_runner_type", additional_properties: {label: "instance_type", value: 9.36})
Related to #481877 (closed)

