Commit 4d8107ee authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'add-snowplow-service-ping' into 'master'

Add snowplow stats enabled metric

See merge request gitlab-org/gitlab!75184
parents 2a4bc2a7 db463818
---
key_path: settings.snowplow_enabled
name: snowplow_enabled_gitlab_instance
description: Whether snowplow is enabled for the GitLab instance
product_section: growth
product_stage: growth
product_group: group::product intelligence
product_category: product intelligence
value_type: boolean
status: active
milestone: "14.6"
introduced_by_url: 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75184'
time_frame: none
data_source: system
instrumentation_class: SnowplowEnabledMetric
data_category: optional
performance_indicator_type: []
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: settings.snowplow_configured_to_gitlab_collector
name: snowplow_configured_to_gitlab_collector
description: Metric informs if currently configured Snowplow collector hostname points towards Gitlab Snowplow collection pipeline.
product_section: growth
product_stage: growth
product_group: group::product intelligence
product_category: product intelligence
value_type: boolean
status: active
milestone: "14.6"
introduced_by_url: 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75184'
time_frame: none
data_source: system
instrumentation_class: SnowplowConfiguredToGitlabCollectorMetric
data_category: optional
performance_indicator_type: []
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
class SnowplowConfiguredToGitlabCollectorMetric < GenericMetric
GITLAB_SNOWPLOW_COLLECTOR_HOSTNAME = 'snowplow.trx.gitlab.net'
def value
Gitlab::CurrentSettings.snowplow_collector_hostname == GITLAB_SNOWPLOW_COLLECTOR_HOSTNAME
end
end
end
end
end
end
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
class SnowplowEnabledMetric < GenericMetric
def value
Gitlab::CurrentSettings.snowplow_enabled?
end
end
end
end
end
end
......@@ -228,7 +228,9 @@ module Gitlab
operating_system: alt_usage_data(fallback: nil) { operating_system },
gitaly_apdex: alt_usage_data { gitaly_apdex },
collected_data_categories: add_metric('CollectedDataCategoriesMetric', time_frame: 'none'),
service_ping_features_enabled: add_metric('ServicePingFeaturesMetric', time_frame: 'none')
service_ping_features_enabled: add_metric('ServicePingFeaturesMetric', time_frame: 'none'),
snowplow_enabled: add_metric('SnowplowEnabledMetric', time_frame: 'none'),
snowplow_configured_to_gitlab_collector: add_metric('SnowplowConfiguredToGitlabCollectorMetric', time_frame: 'none')
}
}
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::SnowplowConfiguredToGitlabCollectorMetric do
using RSpec::Parameterized::TableSyntax
context 'for collector_hostname option' do
where(:collector_hostname, :expected_value) do
'snowplow.trx.gitlab.net' | true
'foo.bar.something.net' | false
end
with_them do
before do
stub_application_setting(snowplow_collector_hostname: collector_hostname)
end
it_behaves_like 'a correct instrumented metric value', { time_frame: 'none' }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::SnowplowEnabledMetric do
using RSpec::Parameterized::TableSyntax
context 'for snowplow enabled option' do
where(:snowplow_enabled, :expected_value) do
true | true
false | false
end
with_them do
before do
stub_application_setting(snowplow_enabled: snowplow_enabled)
end
it_behaves_like 'a correct instrumented metric value', { time_frame: 'none' }
end
end
end
......@@ -1045,6 +1045,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
describe ".system_usage_data_settings" do
let(:prometheus_client) { double(Gitlab::PrometheusClient) }
let(:snowplow_gitlab_host?) { Gitlab::CurrentSettings.snowplow_collector_hostname == 'snowplow.trx.gitlab.net' }
before do
allow(described_class).to receive(:operating_system).and_return('ubuntu-20.04')
......@@ -1089,6 +1090,17 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
it 'gathers user_cap_feature_enabled' do
expect(subject[:settings][:user_cap_feature_enabled]).to eq(Gitlab::CurrentSettings.new_user_signups_cap)
end
context 'snowplow stats' do
before do
stub_feature_flags(usage_data_instrumentation: false)
end
it 'gathers snowplow stats' do
expect(subject[:settings][:snowplow_enabled]).to eq(Gitlab::CurrentSettings.snowplow_enabled?)
expect(subject[:settings][:snowplow_configured_to_gitlab_collector]).to eq(snowplow_gitlab_host?)
end
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