diff --git a/app/models/project.rb b/app/models/project.rb index 7e4ec6c7036664ce6e1e2e643af2daf0bb16ea2f..d002d7edeb553a6a5f4d858a0a4687959c8ce19c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -571,6 +571,7 @@ class Project < ApplicationRecord scope :imported_from, -> (type) { where(import_type: type) } scope :with_tracing_enabled, -> { joins(:tracing_setting) } + scope :with_enabled_error_tracking, -> { joins(:error_tracking_setting).where(project_error_tracking_settings: { enabled: true }) } enum auto_cancel_pending_pipelines: { disabled: 0, enabled: 1 } diff --git a/changelogs/unreleased/250323-move-projects_with_error_tracking_enabled-to-core.yml b/changelogs/unreleased/250323-move-projects_with_error_tracking_enabled-to-core.yml new file mode 100644 index 0000000000000000000000000000000000000000..8a602a858bd9846647486a6b3abc650ebaca0a1f --- /dev/null +++ b/changelogs/unreleased/250323-move-projects_with_error_tracking_enabled-to-core.yml @@ -0,0 +1,5 @@ +--- +title: Moves projects_with_error_tracking_enabled ping usage to Core +merge_request: 46556 +author: +type: changed diff --git a/ee/app/models/ee/project.rb b/ee/app/models/ee/project.rb index 8d3a619e7fb104a9b08b02b04f88aaadaca78511..7f8d325c6737fef5fa84f144579f3559daf15304 100644 --- a/ee/app/models/ee/project.rb +++ b/ee/app/models/ee/project.rb @@ -134,7 +134,6 @@ def lock_for_confirmation!(id) scope :with_security_reports, -> { where('EXISTS (?)', ::Ci::JobArtifact.security_reports.scoped_project.select(1)) } 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_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 joins(:project_feature).mirror.where(mirror_trigger_builds: true, diff --git a/ee/lib/ee/gitlab/usage_data.rb b/ee/lib/ee/gitlab/usage_data.rb index 0eb6d900f53019ca24155d50386e0b58ab21445e..4e8d5d509bc057301632e0abf737dafad6a615d3 100644 --- a/ee/lib/ee/gitlab/usage_data.rb +++ b/ee/lib/ee/gitlab/usage_data.rb @@ -294,7 +294,6 @@ def usage_activity_by_stage_monitor(time_period) super.merge({ 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_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 diff --git a/ee/spec/lib/ee/gitlab/usage_data_spec.rb b/ee/spec/lib/ee/gitlab/usage_data_spec.rb index 2818088e58cc5b641a3ee27bef56f73d699a6e28..0c6b042bedf81eef93fa6e66cbed9cda734b498f 100644 --- a/ee/spec/lib/ee/gitlab/usage_data_spec.rb +++ b/ee/spec/lib/ee/gitlab/usage_data_spec.rb @@ -436,20 +436,17 @@ def ldap_server_config project = create(:project, creator: user) create(:users_ops_dashboard_project, user: user) create(:prometheus_service, project: project) - create(:project_error_tracking_setting, project: project) create(:project_incident_management_setting, :sla_enabled, project: project) end expect(described_class.usage_activity_by_stage_monitor({})).to include( operations_dashboard_users_with_projects_added: 2, projects_prometheus_active: 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( operations_dashboard_users_with_projects_added: 1, projects_prometheus_active: 1, - projects_with_error_tracking_enabled: 1, projects_incident_sla_enabled: 2 ) end diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index ab49c3e682998fe308f412682fa2164102202bf5..c4c372b0806bd892bbf2627f5408e97f06432676 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -617,7 +617,8 @@ def usage_activity_by_stage_monitor(time_period) operations_dashboard_default_dashboard: count(::User.active.with_dashboard('operations').where(time_period), start: user_minimum_id, finish: user_maximum_id), - projects_with_tracing_enabled: distinct_count(::Project.with_tracing_enabled.where(time_period), :creator_id) + projects_with_tracing_enabled: distinct_count(::Project.with_tracing_enabled.where(time_period), :creator_id), + projects_with_error_tracking_enabled: distinct_count(::Project.with_enabled_error_tracking.where(time_period), :creator_id) } end # rubocop: enable CodeReuse/ActiveRecord diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 63a050e4f56116197b6c83ff2e31159af4102e29..243da628204facfbb1c26378f99d60e6b5e67035 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -294,19 +294,22 @@ def omniauth_providers create(:project, creator: user) create(:clusters_applications_prometheus, :installed, cluster: cluster) create(:project_tracing_setting) + create(:project_error_tracking_setting) end expect(described_class.usage_activity_by_stage_monitor({})).to include( clusters: 2, clusters_applications_prometheus: 2, operations_dashboard_default_dashboard: 2, - projects_with_tracing_enabled: 2 + projects_with_tracing_enabled: 2, + projects_with_error_tracking_enabled: 2 ) expect(described_class.usage_activity_by_stage_monitor(described_class.last_28_days_time_period)).to include( clusters: 1, clusters_applications_prometheus: 1, operations_dashboard_default_dashboard: 1, - projects_with_tracing_enabled: 1 + projects_with_tracing_enabled: 1, + projects_with_error_tracking_enabled: 1 ) end end