Commit 9179c6fc authored by Krasimir Angelov's avatar Krasimir Angelov

Add database.flavor to usage data

https://gitlab.com/gitlab-org/database-team/team-tasks/-/issues/218

Changelog: added
parent a8e254a5
---
key_path: database.flavor
description: What PostgreSQL flavor is being used. Possible values are
"Amazon Aurora PostgreSQL", "PostgreSQL on Amazon RDS", "Cloud SQL for PostgreSQL",
"Azure Database for PostgreSQL - Single Server", "Azure Database for PostgreSQL - Flexible Server",
or "null".
product_section: enablement
product_stage: enablement
product_group: group::database
product_category: database
value_type: string
status: active
milestone: "14.6"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75587
time_frame: none
data_source: system
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
......@@ -311,7 +311,8 @@ The following is example content of the Service Ping payload.
"database": {
"adapter": "postgresql",
"version": "9.6.15",
"pg_system_id": 6842684531675334351
"pg_system_id": 6842684531675334351,
"flavor": "Cloud SQL for PostgreSQL"
},
"analytics_unique_visits": {
"g_analytics_contribution": 999,
......@@ -435,6 +436,10 @@ The following is example content of the Service Ping payload.
## Notable changes
In GitLab 14.6, [`flavor`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75587) was added to try to detect the underlying managed database variant.
Possible values are "Amazon Aurora PostgreSQL", "PostgreSQL on Amazon RDS", "Cloud SQL for PostgreSQL",
"Azure Database for PostgreSQL - Flexible Server", or "null".
In GitLab 13.5, `pg_system_id` was added to send the [PostgreSQL system identifier](https://www.2ndquadrant.com/en/blog/support-for-postgresqls-system-identifier-in-barman/).
## Export Service Ping SQL queries and definitions
......
......@@ -7,6 +7,7 @@ RSpec.describe Gitlab::UsageDataNonSqlMetrics do
before do
stub_usage_data_connections
stub_database_flavor_check
end
describe '.uncached_data' do
......
......@@ -7,6 +7,7 @@ RSpec.describe Gitlab::UsageData do
before do
stub_usage_data_connections
stub_database_flavor_check
clear_memoized_values(described_class::EE_MEMOIZED_VALUES + described_class::CE_MEMOIZED_VALUES)
end
......
......@@ -304,7 +304,8 @@ module Gitlab
# rubocop: disable UsageData/LargeTable
adapter: alt_usage_data { ApplicationRecord.database.adapter_name },
version: alt_usage_data { ApplicationRecord.database.version },
pg_system_id: alt_usage_data { ApplicationRecord.database.system_id }
pg_system_id: alt_usage_data { ApplicationRecord.database.system_id },
flavor: alt_usage_data { ApplicationRecord.database.flavor }
# rubocop: enable UsageData/LargeTable
},
mail: {
......
......@@ -62,6 +62,7 @@ RSpec.describe Admin::ApplicationSettingsController, :do_not_mock_admin_mode_set
describe 'GET #usage_data' do
before do
stub_usage_data_connections
stub_database_flavor_check
sign_in(admin)
end
......
......@@ -22,6 +22,7 @@ RSpec.describe Admin::InstanceReviewController do
before do
stub_application_setting(usage_ping_enabled: true)
stub_usage_data_connections
stub_database_flavor_check
::Gitlab::UsageData.data(force_refresh: true)
subject
end
......
......@@ -530,6 +530,7 @@ RSpec.describe 'Admin updates settings' do
it 'loads usage ping payload on click', :js do
stub_usage_data_connections
stub_database_flavor_check
page.within('#js-usage-settings') do
expected_payload_content = /(?=.*"uuid")(?=.*"hostname")/m
......
......@@ -9,6 +9,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
stub_usage_data_connections
stub_object_store_settings
clear_memoized_values(described_class::CE_MEMOIZED_VALUES)
stub_database_flavor_check('Cloud SQL for PostgreSQL')
end
describe '.uncached_data' do
......@@ -920,6 +921,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(subject[:database][:adapter]).to eq(ApplicationRecord.database.adapter_name)
expect(subject[:database][:version]).to eq(ApplicationRecord.database.version)
expect(subject[:database][:pg_system_id]).to eq(ApplicationRecord.database.system_id)
expect(subject[:database][:flavor]).to eq('Cloud SQL for PostgreSQL')
expect(subject[:mail][:smtp_server]).to eq(ActionMailer::Base.smtp_settings[:address])
expect(subject[:gitaly][:version]).to be_present
expect(subject[:gitaly][:servers]).to be >= 1
......
......@@ -18,6 +18,7 @@ RSpec.describe API::UsageDataNonSqlMetrics do
context 'with authentication' do
before do
stub_feature_flags(usage_data_non_sql_metrics: true)
stub_database_flavor_check
end
it 'returns non sql metrics if user is admin' do
......
......@@ -10,6 +10,7 @@ RSpec.describe API::UsageDataQueries do
before do
stub_usage_data_connections
stub_database_flavor_check
end
describe 'GET /usage_data/usage_data_queries' do
......
......@@ -110,6 +110,7 @@ RSpec.describe ServicePing::SubmitService do
context 'when product_intelligence_enabled is true' do
before do
stub_usage_data_connections
stub_database_flavor_check
allow(ServicePing::ServicePingSettings).to receive(:product_intelligence_enabled?).and_return(true)
end
......@@ -126,6 +127,7 @@ RSpec.describe ServicePing::SubmitService do
context 'when usage ping is enabled' do
before do
stub_usage_data_connections
stub_database_flavor_check
stub_application_setting(usage_ping_enabled: true)
end
......
......@@ -183,6 +183,10 @@ module UsageDataHelpers
)
end
def stub_database_flavor_check(flavor = nil)
allow(ApplicationRecord.database).to receive(:flavor).and_return(flavor)
end
def clear_memoized_values(values)
values.each { |v| described_class.clear_memoization(v) }
end
......
......@@ -2,6 +2,8 @@
RSpec.shared_examples 'service ping payload with all expected metrics' do
specify do
allow(ApplicationRecord.database).to receive(:flavor).and_return(nil)
aggregate_failures do
expected_metrics.each do |metric|
is_expected.to have_usage_metric metric['key_path']
......
......@@ -2,6 +2,8 @@
RSpec.shared_examples 'service ping payload without restricted metrics' do
specify do
allow(ApplicationRecord.database).to receive(:flavor).and_return(nil)
aggregate_failures do
restricted_metrics.each do |metric|
is_expected.not_to have_usage_metric metric['key_path']
......
......@@ -9,6 +9,7 @@ RSpec.describe 'gitlab:usage data take tasks', :silence_stdout do
Rake.application.rake_require 'tasks/gitlab/usage_data'
# stub prometheus external http calls https://gitlab.com/gitlab-org/gitlab/-/issues/245277
stub_prometheus_queries
stub_database_flavor_check
end
describe 'dump_sql_in_yaml' do
......
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