Commit 73495489 authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch 'add-metrics-definition-for-advanced-search' into 'master'

Add advanced_search metrics to the definition

See merge request gitlab-org/gitlab!81003
parents 72800e57 66057046
key_path: advanced_search.version
description: Advanced Search search engine server version
product_section: enablement
product_stage: enablement
product_group: group::global search
value_type: string
status: active
milestone: "14.9"
instrumentation_class: AdvancedSearch::DistributionMetric
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81003
time_frame: none
data_source: system
data_category: optional
distribution:
- ee
tier:
- premium
- ultimate
key_path: advanced_search.distribution
description: Advanced Search search engine distribution
product_section: enablement
product_stage: enablement
product_group: group::global search
value_type: string
status: active
milestone: "14.9"
instrumentation_class: AdvancedSearch::VersionMetric
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81003
time_frame: none
data_source: system
data_category: optional
distribution:
- ee
tier:
- premium
- ultimate
key_path: advanced_search.build_type
description: Advanced Search search engine build_type
product_section: enablement
product_stage: enablement
product_group: group::global search
value_type: string
status: active
milestone: "14.9"
instrumentation_class: AdvancedSearch::BuildTypeMetric
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81003
time_frame: none
data_source: system
data_category: optional
distribution:
- ee
tier:
- premium
- ultimate
key_path: advanced_search.lucene_version
description: Advanced Search search engine lucene version
product_section: enablement
product_stage: enablement
product_group: group::global search
value_type: string
status: active
milestone: "14.9"
instrumentation_class: AdvancedSearch::LuceneVersionMetric
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81003
time_frame: none
data_source: system
data_category: optional
distribution:
- ee
tier:
- premium
- ultimate
......@@ -109,9 +109,12 @@ module EE
def components_usage_data
usage_data = super
if ::Gitlab::CurrentSettings.elasticsearch_indexing?
usage_data[:advanced_search] = add_metric("AdvancedSearchMetric")
end
usage_data[:advanced_search] = {
distribution: add_metric("AdvancedSearch::DistributionMetric"),
version: add_metric("AdvancedSearch::VersionMetric"),
build_type: add_metric("AdvancedSearch::BuildTypeMetric"),
lucene_version: add_metric("AdvancedSearch::LuceneVersionMetric")
}
usage_data
end
......
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
module AdvancedSearch
class BuildTypeMetric < GenericMetric
value do
if ::Gitlab::CurrentSettings.elasticsearch_indexing?
::Gitlab::Elastic::Helper.default.server_info[:build_type]
else
'NA'
end
end
end
end
end
end
end
end
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
module AdvancedSearch
class DistributionMetric < GenericMetric
value do
if ::Gitlab::CurrentSettings.elasticsearch_indexing?
::Gitlab::Elastic::Helper.default.server_info[:distribution]
else
'NA'
end
end
end
end
end
end
end
end
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
module AdvancedSearch
class LuceneVersionMetric < GenericMetric
value do
if ::Gitlab::CurrentSettings.elasticsearch_indexing?
::Gitlab::Elastic::Helper.default.server_info[:lucene_version]
else
'NA'
end
end
end
end
end
end
end
end
......@@ -4,11 +4,15 @@ module Gitlab
module Usage
module Metrics
module Instrumentations
class AdvancedSearchMetric < GenericMetric
fallback({})
value do
::Gitlab::Elastic::Helper.default.server_info
module AdvancedSearch
class VersionMetric < GenericMetric
value do
if ::Gitlab::CurrentSettings.elasticsearch_indexing?
::Gitlab::Elastic::Helper.default.server_info[:version]
else
'NA'
end
end
end
end
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::AdvancedSearch::BuildTypeMetric do
let(:mock_es_helper) { instance_double(Gitlab::Elastic::Helper, server_info: { build_type: 'docker' }) }
before do
allow(Gitlab::Elastic::Helper).to receive(:default).and_return(mock_es_helper)
end
it_behaves_like 'a correct instrumented metric value', { data_source: 'system' } do
before do
expect(mock_es_helper).not_to receive(:server_info)
end
let(:expected_value) { 'NA' }
end
context 'elasticsearch_indexing is enabled' do
before do
stub_ee_application_setting(elasticsearch_indexing: true)
end
it_behaves_like 'a correct instrumented metric value', { data_source: 'system' } do
let(:expected_value) { 'docker' }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::AdvancedSearch::DistributionMetric do
let(:mock_es_helper) { instance_double(Gitlab::Elastic::Helper, server_info: { distribution: 'elasticsearch' }) }
before do
allow(Gitlab::Elastic::Helper).to receive(:default).and_return(mock_es_helper)
end
it_behaves_like 'a correct instrumented metric value', { time_frame: 'all', data_source: 'system' } do
before do
expect(mock_es_helper).not_to receive(:server_info)
end
let(:expected_value) { 'NA' }
end
context 'elasticsearch_indexing is enabled' do
before do
stub_ee_application_setting(elasticsearch_indexing: true)
end
it_behaves_like 'a correct instrumented metric value', { time_frame: 'all', data_source: 'system' } do
let(:expected_value) { 'elasticsearch' }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::AdvancedSearch::LuceneVersionMetric do
let(:mock_es_helper) { instance_double(Gitlab::Elastic::Helper, server_info: { lucene_version: '8.11' }) }
before do
allow(Gitlab::Elastic::Helper).to receive(:default).and_return(mock_es_helper)
end
it_behaves_like 'a correct instrumented metric value', { data_source: 'system' } do
before do
expect(mock_es_helper).not_to receive(:server_info)
end
let(:expected_value) { 'NA' }
end
context 'elasticsearch_indexing is enabled' do
before do
stub_ee_application_setting(elasticsearch_indexing: true)
end
it_behaves_like 'a correct instrumented metric value', { data_source: 'system' } do
let(:expected_value) { '8.11' }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::AdvancedSearch::VersionMetric do
let(:mock_es_helper) { instance_double(Gitlab::Elastic::Helper, server_info: { version: '7.17' }) }
before do
allow(Gitlab::Elastic::Helper).to receive(:default).and_return(mock_es_helper)
end
it_behaves_like 'a correct instrumented metric value', { data_source: 'system' } do
before do
expect(mock_es_helper).not_to receive(:server_info)
end
let(:expected_value) { 'NA' }
end
context 'elasticsearch_indexing is enabled' do
before do
stub_ee_application_setting(elasticsearch_indexing: true)
end
it_behaves_like 'a correct instrumented metric value', { data_source: 'system' } do
let(:expected_value) { '7.17' }
end
end
end
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