Commit 366d29f8 authored by Stan Hu's avatar Stan Hu

Add CI runner counts to usage ping

This commit adds a number of new metrics:

* ci_runners_active: The number of active runners
* ci_runners_instance_type_active: The number of active instance runners
* ci_runners_group_type_active: The number of active group runners
* ci_runners_project_type_active: The number of active project runners
* ci_runners_instance_type_active_online: The number of active and
  online instance runners
* ci_runners_group_type_active_online: The number of active and online
  group runners
* ci_runners_project_type_active_online: The number of active and online
  project runners

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/27141

Changelog: added
parent 61318cf1
---
title: Add CI runner counts to usage ping
merge_request: 58197
author:
type: added
---
key_path: counts.ci_runners_instance_type_active
name: "count_active_instance_ci_runners"
description: Total active group Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.ci_runners_group_type_active
name: "count_active_group_ci_runners"
description: Total active instance Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.ci_runners_project_type_active
name: "count_active_project_ci_runners"
description: Total active project Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.ci_runners_online
name: "counts_online_runners"
description: Total online Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.ci_runners_instance_type_active_online
name: "count_instance_active_online_ci_runners"
description: Total active and online instance Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.ci_runners_group_type_active_online
name: "count_group_active_online_ci_runners"
description: Total active and online group Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.ci_runners_project_type_active_online
name: "count_project_active_online_ci_runners"
description: Total active and online project Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
......@@ -98,7 +98,6 @@ module Gitlab
ci_external_pipelines: count(::Ci::Pipeline.external),
ci_pipeline_config_auto_devops: count(::Ci::Pipeline.auto_devops_source),
ci_pipeline_config_repository: count(::Ci::Pipeline.repository_source),
ci_runners: count(::Ci::Runner),
ci_triggers: count(::Ci::Trigger),
ci_pipeline_schedules: count(::Ci::PipelineSchedule),
auto_devops_enabled: count(::ProjectAutoDevops.enabled),
......@@ -185,6 +184,7 @@ module Gitlab
merge_requests: count(MergeRequest),
notes: count(Note)
}.merge(
runners_usage,
services_usage,
usage_counters,
user_preferences_usage,
......@@ -198,6 +198,18 @@ module Gitlab
end
# rubocop: enable Metrics/AbcSize
def runners_usage
{
ci_runners: count(::Ci::Runner),
ci_runners_instance_type_active: count(::Ci::Runner.instance_type.active),
ci_runners_group_type_active: count(::Ci::Runner.group_type.active),
ci_runners_project_type_active: count(::Ci::Runner.project_type.active),
ci_runners_instance_type_active_online: count(::Ci::Runner.instance_type.active.online),
ci_runners_group_type_active_online: count(::Ci::Runner.group_type.active.online),
ci_runners_project_type_active_online: count(::Ci::Runner.project_type.active.online)
}
end
def snowplow_event_counts(time_period)
return {} unless report_snowplow_events?
......
......@@ -744,6 +744,29 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
end
describe '.runners_usage' do
before do
project = build(:project)
create_list(:ci_runner, 2, :instance_type, :online)
create(:ci_runner, :group, :online)
create(:ci_runner, :group, :inactive)
create_list(:ci_runner, 3, :project_type, :online, projects: [project])
end
subject { described_class.runners_usage }
it 'gathers runner usage counts correctly' do
expect(subject[:ci_runners]).to eq(7)
expect(subject[:ci_runners_instance_type_active]).to eq(2)
expect(subject[:ci_runners_group_type_active]).to eq(1)
expect(subject[:ci_runners_project_type_active]).to eq(3)
expect(subject[:ci_runners_instance_type_active_online]).to eq(2)
expect(subject[:ci_runners_group_type_active_online]).to eq(1)
expect(subject[:ci_runners_project_type_active_online]).to eq(3)
end
end
describe '.usage_counters' do
subject { described_class.usage_counters }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment