From e61b83ba458bd7fd90492069e0e882255c35815c Mon Sep 17 00:00:00 2001 From: Bojan Marjanovic <bmarjanovic@gitlab.com> Date: Tue, 7 Nov 2023 12:46:28 +0000 Subject: [PATCH] Remove `projects_jira_dvcs_cloud_active` metric --- app/models/project_feature_usage.rb | 13 ----- ...180232_projects_jira_dvcs_cloud_active.yml | 4 +- ..._with_jira_dvcs_integration_metric_spec.rb | 50 ------------------- 3 files changed, 3 insertions(+), 64 deletions(-) delete mode 100644 spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_jira_dvcs_integration_metric_spec.rb diff --git a/app/models/project_feature_usage.rb b/app/models/project_feature_usage.rb index dba81a6cb60c2..5e47ec6310d40 100644 --- a/app/models/project_feature_usage.rb +++ b/app/models/project_feature_usage.rb @@ -19,19 +19,6 @@ def jira_dvcs_integration_field(cloud: true) end end - def log_jira_dvcs_integration_usage(cloud: true) - ::Gitlab::Database::LoadBalancing::Session.without_sticky_writes do - integration_field = self.class.jira_dvcs_integration_field(cloud: cloud) - - # The feature usage is used only once later to query the feature usage in a - # long date range. Therefore, we just need to update the timestamp once per - # day - break if persisted? && updated_today?(integration_field) - - persist_jira_dvcs_usage(integration_field) - end - end - private def updated_today?(integration_field) diff --git a/config/metrics/counts_all/20210216180232_projects_jira_dvcs_cloud_active.yml b/config/metrics/counts_all/20210216180232_projects_jira_dvcs_cloud_active.yml index 5bf8e1d6e7820..c9c85bca41513 100644 --- a/config/metrics/counts_all/20210216180232_projects_jira_dvcs_cloud_active.yml +++ b/config/metrics/counts_all/20210216180232_projects_jira_dvcs_cloud_active.yml @@ -6,7 +6,7 @@ product_section: dev product_stage: manage product_group: integrations value_type: number -status: active +status: removed time_frame: all data_source: database instrumentation_class: CountProjectsWithJiraDvcsIntegrationMetric @@ -21,3 +21,5 @@ tier: - ultimate performance_indicator_type: [] milestone: "<13.9" +removed_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/135755 +milestone_removed: "<16.6" diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_jira_dvcs_integration_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_jira_dvcs_integration_metric_spec.rb deleted file mode 100644 index a2d86fc504442..0000000000000 --- a/spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_jira_dvcs_integration_metric_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Gitlab::Usage::Metrics::Instrumentations::CountProjectsWithJiraDvcsIntegrationMetric, - feature_category: :integrations do - describe 'metric value and query' do - let_it_be_with_reload(:project_1) { create(:project) } - let_it_be_with_reload(:project_2) { create(:project) } - let_it_be_with_reload(:project_3) { create(:project) } - - before do - project_1.feature_usage.log_jira_dvcs_integration_usage(cloud: false) - project_2.feature_usage.log_jira_dvcs_integration_usage(cloud: false) - project_3.feature_usage.log_jira_dvcs_integration_usage(cloud: true) - end - - context 'when counting cloud integrations' do - let(:expected_value) { 1 } - let(:expected_query) do - 'SELECT COUNT("project_feature_usages"."project_id") FROM "project_feature_usages" ' \ - 'WHERE "project_feature_usages"."jira_dvcs_cloud_last_sync_at" IS NOT NULL' - end - - it_behaves_like 'a correct instrumented metric value and query', { time_frame: 'all', options: { cloud: true } } - end - - context 'when counting non-cloud integrations' do - let(:expected_value) { 2 } - let(:expected_query) do - 'SELECT COUNT("project_feature_usages"."project_id") FROM "project_feature_usages" ' \ - 'WHERE "project_feature_usages"."jira_dvcs_server_last_sync_at" IS NOT NULL' - end - - it_behaves_like 'a correct instrumented metric value and query', { time_frame: 'all', options: { cloud: false } } - end - end - - it "raises an exception if option is not present" do - expect do - described_class.new(options: {}, time_frame: 'all') - end.to raise_error(ArgumentError, %r{must be a boolean}) - end - - it "raises an exception if option has invalid value" do - expect do - described_class.new(options: { cloud: 'yes' }, time_frame: 'all') - end.to raise_error(ArgumentError, %r{must be a boolean}) - end -end -- GitLab