Commit ad7f689f authored by Sean Arnold's avatar Sean Arnold Committed by Peter Leitzen

Add projects_incident_sla_enabled metric to usage data

We are skipping the time period last 28 days.
parent 5247e5ae
...@@ -135,6 +135,7 @@ module EE ...@@ -135,6 +135,7 @@ module EE
scope :with_github_service_pipeline_events, -> { joins(:github_service).merge(GithubService.pipeline_hooks) } scope :with_github_service_pipeline_events, -> { joins(:github_service).merge(GithubService.pipeline_hooks) }
scope :with_active_prometheus_service, -> { joins(:prometheus_service).merge(PrometheusService.active) } scope :with_active_prometheus_service, -> { joins(:prometheus_service).merge(PrometheusService.active) }
scope :with_enabled_error_tracking, -> { joins(:error_tracking_setting).where(project_error_tracking_settings: { enabled: true }) } scope :with_enabled_error_tracking, -> { joins(:error_tracking_setting).where(project_error_tracking_settings: { enabled: true }) }
scope :with_enabled_incident_sla, -> { joins(:incident_management_setting).where(project_incident_management_settings: { sla_timer: true }) }
scope :mirrored_with_enabled_pipelines, -> do scope :mirrored_with_enabled_pipelines, -> do
joins(:project_feature).mirror.where(mirror_trigger_builds: true, joins(:project_feature).mirror.where(mirror_trigger_builds: true,
project_features: { builds_access_level: ::ProjectFeature::ENABLED }) project_features: { builds_access_level: ::ProjectFeature::ENABLED })
......
---
title: Add metric count for projects with incident sla enabled
merge_request: 45092
author:
type: added
...@@ -294,7 +294,8 @@ module EE ...@@ -294,7 +294,8 @@ module EE
super.merge({ super.merge({
operations_dashboard_users_with_projects_added: distinct_count(UsersOpsDashboardProject.joins(:user).merge(::User.active).where(time_period), :user_id), operations_dashboard_users_with_projects_added: distinct_count(UsersOpsDashboardProject.joins(:user).merge(::User.active).where(time_period), :user_id),
projects_prometheus_active: distinct_count(::Project.with_active_prometheus_service.where(time_period), :creator_id), projects_prometheus_active: distinct_count(::Project.with_active_prometheus_service.where(time_period), :creator_id),
projects_with_error_tracking_enabled: distinct_count(::Project.with_enabled_error_tracking.where(time_period), :creator_id) projects_with_error_tracking_enabled: distinct_count(::Project.with_enabled_error_tracking.where(time_period), :creator_id),
projects_incident_sla_enabled: count(::Project.with_enabled_incident_sla)
}) })
end end
......
...@@ -4,5 +4,10 @@ FactoryBot.modify do ...@@ -4,5 +4,10 @@ FactoryBot.modify do
factory :project_incident_management_setting, class: 'IncidentManagement::ProjectIncidentManagementSetting' do factory :project_incident_management_setting, class: 'IncidentManagement::ProjectIncidentManagementSetting' do
sla_timer { false } sla_timer { false }
sla_timer_minutes { nil } sla_timer_minutes { nil }
trait :sla_enabled do
sla_timer { true }
sla_timer_minutes { 15 }
end
end end
end end
...@@ -437,17 +437,20 @@ RSpec.describe Gitlab::UsageData do ...@@ -437,17 +437,20 @@ RSpec.describe Gitlab::UsageData do
create(:users_ops_dashboard_project, user: user) create(:users_ops_dashboard_project, user: user)
create(:prometheus_service, project: project) create(:prometheus_service, project: project)
create(:project_error_tracking_setting, project: project) create(:project_error_tracking_setting, project: project)
create(:project_incident_management_setting, :sla_enabled, project: project)
end end
expect(described_class.usage_activity_by_stage_monitor({})).to include( expect(described_class.usage_activity_by_stage_monitor({})).to include(
operations_dashboard_users_with_projects_added: 2, operations_dashboard_users_with_projects_added: 2,
projects_prometheus_active: 2, projects_prometheus_active: 2,
projects_with_error_tracking_enabled: 2 projects_with_error_tracking_enabled: 2,
projects_incident_sla_enabled: 2
) )
expect(described_class.usage_activity_by_stage_monitor(described_class.last_28_days_time_period)).to include( expect(described_class.usage_activity_by_stage_monitor(described_class.last_28_days_time_period)).to include(
operations_dashboard_users_with_projects_added: 1, operations_dashboard_users_with_projects_added: 1,
projects_prometheus_active: 1, projects_prometheus_active: 1,
projects_with_error_tracking_enabled: 1 projects_with_error_tracking_enabled: 1,
projects_incident_sla_enabled: 2
) )
end end
end end
......
...@@ -195,6 +195,16 @@ RSpec.describe Project do ...@@ -195,6 +195,16 @@ RSpec.describe Project do
end end
end end
describe '.with_enabled_incident_sla' do
it 'returns the correct project' do
project_with_enabled_incident_sla = create(:project_incident_management_setting, :sla_enabled).project
project_without_enabled_incident_sla = create(:project_incident_management_setting).project
expect(described_class.with_enabled_incident_sla).to include(project_with_enabled_incident_sla)
expect(described_class.with_enabled_incident_sla).not_to include(project_without_enabled_incident_sla)
end
end
describe '.with_shared_runners_limit_enabled' do describe '.with_shared_runners_limit_enabled' do
let(:public_cost_factor) { 1.0 } let(:public_cost_factor) { 1.0 }
......
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