Commit c260eed3 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch 'pl-tracing-core-2-usage-data' into 'master'

Move Tracing usage data ping to Core [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!44006
parents e75214dc 74c2c527
......@@ -565,6 +565,7 @@ class Project < ApplicationRecord
}
scope :imported_from, -> (type) { where(import_type: type) }
scope :with_tracing_enabled, -> { joins(:tracing_setting) }
enum auto_cancel_pending_pipelines: { disabled: 0, enabled: 1 }
......
---
title: Move Tracing usage data ping to Core
merge_request: 44006
author:
type: added
......@@ -135,7 +135,6 @@ module EE
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_tracing_enabled, -> { joins(:tracing_setting) }
scope :mirrored_with_enabled_pipelines, -> do
joins(:project_feature).mirror.where(mirror_trigger_builds: true,
project_features: { builds_access_level: ::ProjectFeature::ENABLED })
......
......@@ -193,7 +193,6 @@ module EE
merge_requests_with_required_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_required, :merge_request_id),
projects_mirrored_with_pipelines_enabled: count(::Project.mirrored_with_enabled_pipelines),
projects_reporting_ci_cd_back_to_github: count(::GithubService.active),
projects_with_tracing_enabled: count(ProjectTracingSetting),
status_page_projects: count(::StatusPage::ProjectSetting.enabled),
status_page_issues: count(::Issue.on_status_page, start: issue_minimum_id, finish: issue_maximum_id),
template_repositories: count(::Project.with_repos_templates) + count(::Project.with_groups_level_repos_templates)
......@@ -283,8 +282,7 @@ module EE
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_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
......
......@@ -37,7 +37,6 @@ RSpec.describe Gitlab::UsageData do
create(:service, project: projects[1], type: 'JenkinsService', active: true)
create(:jira_service, project: projects[0], issues_enabled: true, project_key: 'GL')
create(:project_tracing_setting, project: projects[0])
create(:operations_feature_flag, project: projects[0])
create(:issue, project: projects[1])
......@@ -107,7 +106,6 @@ RSpec.describe Gitlab::UsageData do
projects_mirrored_with_pipelines_enabled
projects_reporting_ci_cd_back_to_github
projects_with_prometheus_alerts
projects_with_tracing_enabled
sast_jobs
secret_detection_jobs
status_page_incident_publishes
......@@ -422,20 +420,17 @@ RSpec.describe Gitlab::UsageData do
create(:users_ops_dashboard_project, user: user)
create(:prometheus_service, project: project)
create(:project_error_tracking_setting, project: project)
create(:project_tracing_setting, 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_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(
operations_dashboard_users_with_projects_added: 1,
projects_prometheus_active: 1,
projects_with_error_tracking_enabled: 1,
projects_with_tracing_enabled: 1
projects_with_error_tracking_enabled: 1
)
end
end
......
......@@ -141,6 +141,7 @@ module Gitlab
projects_creating_incidents: distinct_count(Issue.incident, :project_id),
projects_imported_from_github: count(Project.where(import_type: 'github')),
projects_with_repositories_enabled: count(ProjectFeature.where('repository_access_level > ?', ProjectFeature::DISABLED)),
projects_with_tracing_enabled: count(ProjectTracingSetting),
projects_with_error_tracking_enabled: count(::ErrorTracking::ProjectErrorTrackingSetting.where(enabled: true)),
projects_with_alerts_service_enabled: count(AlertsService.active),
projects_with_prometheus_alerts: distinct_count(PrometheusAlert, :project_id),
......@@ -573,7 +574,8 @@ module Gitlab
clusters_applications_prometheus: cluster_applications_user_distinct_count(::Clusters::Applications::Prometheus, time_period),
operations_dashboard_default_dashboard: count(::User.active.with_dashboard('operations').where(time_period),
start: user_minimum_id,
finish: user_maximum_id)
finish: user_maximum_id),
projects_with_tracing_enabled: distinct_count(::Project.with_tracing_enabled.where(time_period), :creator_id)
}
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -50,6 +50,9 @@ FactoryBot.define do
create(:protected_branch, project: projects[0])
create(:protected_branch, name: 'main', project: projects[0])
# Tracing
create(:project_tracing_setting, project: projects[0])
# Incident Labeled Issues
incident_label = create(:label, :incident, project: projects[0])
create(:labeled_issue, project: projects[0], labels: [incident_label])
......
......@@ -285,17 +285,20 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
cluster = create(:cluster, user: user)
create(:project, creator: user)
create(:clusters_applications_prometheus, :installed, cluster: cluster)
create(:project_tracing_setting)
end
expect(described_class.usage_activity_by_stage_monitor({})).to include(
clusters: 2,
clusters_applications_prometheus: 2,
operations_dashboard_default_dashboard: 2
operations_dashboard_default_dashboard: 2,
projects_with_tracing_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
operations_dashboard_default_dashboard: 1,
projects_with_tracing_enabled: 1
)
end
end
......@@ -445,6 +448,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(count_data[:projects_inheriting_instance_mattermost_active]).to eq(1)
expect(count_data[:projects_with_repositories_enabled]).to eq(3)
expect(count_data[:projects_with_error_tracking_enabled]).to eq(1)
expect(count_data[:projects_with_tracing_enabled]).to eq(1)
expect(count_data[:projects_with_alerts_service_enabled]).to eq(1)
expect(count_data[:projects_with_prometheus_alerts]).to eq(2)
expect(count_data[:projects_with_terraform_reports]).to eq(2)
......
......@@ -99,6 +99,7 @@ module UsageDataHelpers
projects_with_error_tracking_enabled
projects_with_alerts_service_enabled
projects_with_prometheus_alerts
projects_with_tracing_enabled
projects_with_expiration_policy_enabled
projects_with_expiration_policy_disabled
projects_with_expiration_policy_enabled_with_keep_n_unset
......
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