From c8f81c2efdfd077f3f3146359a1ac4bd6e5359e4 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 16 Mar 2022 03:07:43 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../components/mr_widget_related_links.vue | 7 +++--- .../admin/application_settings_controller.rb | 7 +++++- ...02_service_usage_data_download_payload.yml | 22 +++++++++++++++++++ doc/integration/elasticsearch.md | 3 +++ lib/gitlab/usage_data_counters.rb | 3 ++- .../service_usage_data_counter.rb | 8 +++++++ .../application_settings_controller_spec.rb | 12 ++++++++++ .../service_usage_data_counter_spec.rb | 7 ++++++ spec/support/helpers/usage_data_helpers.rb | 1 + 9 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 config/metrics/counts_all/20220314362302_service_usage_data_download_payload.yml create mode 100644 lib/gitlab/usage_data_counters/service_usage_data_counter.rb create mode 100644 spec/lib/gitlab/usage_data_counters/service_usage_data_counter_spec.rb diff --git a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.vue b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.vue index 319df090ff1..2cef37d5c2e 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.vue @@ -58,21 +58,22 @@ export default {

{{ closesText }}

+ · {{ n__('mrWidget|Mentions issue', 'mrWidget|Mentions issues', relatedLinks.mentionedCount) }}

{{ diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index f9df0307a01..0dd85376050 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -66,7 +66,12 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController render html: Gitlab::Highlight.highlight('payload.json', usage_data_json, language: 'json') end - format.json { render json: Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values, cached: true).to_json } + + format.json do + Gitlab::UsageDataCounters::ServiceUsageDataCounter.count(:download_payload_click) + + render json: Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values, cached: true).to_json + end end end diff --git a/config/metrics/counts_all/20220314362302_service_usage_data_download_payload.yml b/config/metrics/counts_all/20220314362302_service_usage_data_download_payload.yml new file mode 100644 index 00000000000..0174f9a6222 --- /dev/null +++ b/config/metrics/counts_all/20220314362302_service_usage_data_download_payload.yml @@ -0,0 +1,22 @@ +--- +key_path: counts.service_usage_data_download_payload_click +description: Count Download Payload button clicks +data_category: optional +name: count_promoted_issues +product_section: growth +product_stage: growth +product_group: group::product intelligence +product_category: collection +value_type: number +status: active +time_frame: all +data_source: redis +distribution: + - ce + - ee +tier: + - free + - premium + - ultimate +performance_indicator_type: [] +milestone: "14.9" diff --git a/doc/integration/elasticsearch.md b/doc/integration/elasticsearch.md index f5596448876..5265a24d299 100644 --- a/doc/integration/elasticsearch.md +++ b/doc/integration/elasticsearch.md @@ -58,6 +58,9 @@ source. You must [install it separately](https://www.elastic.co/guide/en/elastic You can install Elasticsearch yourself, or use a cloud hosted offering such as [Elasticsearch Service](https://www.elastic.co/elasticsearch/service) (available on AWS, GCP, or Azure) or the [Amazon OpenSearch](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/gsg.html) service. + +If using the Amazon OpenSearch service, ensure that you select `Elasticsearch 7.10` when configuring Deployment type. As noted in [Versions not supported](#versions-not-supported), Amazon's non-Elasticsearch versions are not yet supported. + You should install Elasticsearch on a separate server. Running Elasticsearch on the same server as GitLab is not recommended and can cause a degradation in GitLab instance performance. For a single node Elasticsearch cluster, the functional cluster health status is always yellow due to the allocation of the primary shard. Elasticsearch cannot assign replica shards to the same node as primary shards. diff --git a/lib/gitlab/usage_data_counters.rb b/lib/gitlab/usage_data_counters.rb index cecc24a38d5..cdcad8fdc7b 100644 --- a/lib/gitlab/usage_data_counters.rb +++ b/lib/gitlab/usage_data_counters.rb @@ -16,7 +16,8 @@ module Gitlab DesignsCounter, KubernetesAgentCounter, StaticSiteEditorCounter, - DiffsCounter + DiffsCounter, + ServiceUsageDataCounter ].freeze UsageDataCounterError = Class.new(StandardError) diff --git a/lib/gitlab/usage_data_counters/service_usage_data_counter.rb b/lib/gitlab/usage_data_counters/service_usage_data_counter.rb new file mode 100644 index 00000000000..aa1d9583ea5 --- /dev/null +++ b/lib/gitlab/usage_data_counters/service_usage_data_counter.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Gitlab::UsageDataCounters + class ServiceUsageDataCounter < BaseCounter + KNOWN_EVENTS = %w[download_payload_click].freeze + PREFIX = 'service_usage_data' + end +end diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb index fb4c0970653..f7b2bab3615 100644 --- a/spec/controllers/admin/application_settings_controller_spec.rb +++ b/spec/controllers/admin/application_settings_controller_spec.rb @@ -81,6 +81,18 @@ RSpec.describe Admin::ApplicationSettingsController, :do_not_mock_admin_mode_set expect(body).to include('counts') expect(response).to have_gitlab_http_status(:ok) end + + describe 'usage data counter' do + let(:counter) { Gitlab::UsageDataCounters::ServiceUsageDataCounter } + + it 'incremented when json generated' do + expect { get :usage_data, format: :json }.to change { counter.read(:download_payload_click) }.by(1) + end + + it 'not incremented when html format requested' do + expect { get :usage_data }.not_to change { counter.read(:download_payload_click) } + end + end end describe 'PUT #update' do diff --git a/spec/lib/gitlab/usage_data_counters/service_usage_data_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/service_usage_data_counter_spec.rb new file mode 100644 index 00000000000..ca6df5b260f --- /dev/null +++ b/spec/lib/gitlab/usage_data_counters/service_usage_data_counter_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::UsageDataCounters::ServiceUsageDataCounter do + it_behaves_like 'a redis usage counter', 'Service Usage Data', :download_payload_click +end diff --git a/spec/support/helpers/usage_data_helpers.rb b/spec/support/helpers/usage_data_helpers.rb index 776ea37ffdc..b9f90b11a69 100644 --- a/spec/support/helpers/usage_data_helpers.rb +++ b/spec/support/helpers/usage_data_helpers.rb @@ -129,6 +129,7 @@ module UsageDataHelpers uploads web_hooks user_preferences_user_gitpod_enabled + service_usage_data_download_payload_click ).push(*SMAU_KEYS) USAGE_DATA_KEYS = %i(