Commit ebbdd30d authored by Dylan Griffith's avatar Dylan Griffith Committed by Sean McGivern

Swap multiple_database_metrics FF for env var

This is because it is quite expensive to be reading this feature flag
every single request. Checking an env var is much more efficient because
feature flags are read from the database.

This feature flag was not user- or administrator-facing.

Changelog: other
parent 447a8ddb
---
name: multiple_database_metrics
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/63490
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/333227
milestone: '14.1'
type: development
group: group::sharding
default_enabled: false
......@@ -31,9 +31,9 @@ From left to right, the performance bar displays:
was sent to the read/write primary server. "Replica" means it was sent
to a read-only replica.
- **Config name**: shows up only when the
`multiple_database_metrics` feature flag is enabled. This is used to
distinguish between different databases configured for different GitLab
features. The name shown is the same name used to configure database
`GITLAB_MULTIPLE_DATABASE_METRICS` environment variable is set. This is
used to distinguish between different databases configured for different
GitLab features. The name shown is the same name used to configure database
connections in GitLab.
- **Gitaly calls**: the time taken (in milliseconds) and the total number of
[Gitaly](../../gitaly/index.md) calls. Click to display a modal window with more
......
......@@ -175,7 +175,7 @@ module Gitlab
DB_LOAD_BALANCING_ROLES.each do |role|
metrics.each do |metric|
counters << compose_metric_key(metric, role)
next unless ::Feature.enabled?(:multiple_database_metrics, default_enabled: :yaml)
next unless ENV['GITLAB_MULTIPLE_DATABASE_METRICS']
::Gitlab::Database.db_config_names.each do |config_name|
counters << compose_metric_key(metric, role, config_name)
......
......@@ -81,7 +81,7 @@ module Peek
end
def format_call_details(call)
if Feature.enabled?(:multiple_database_metrics, default_enabled: :yaml)
if ENV['GITLAB_MULTIPLE_DATABASE_METRICS']
super
else
super.except(:db_config_name)
......
......@@ -109,9 +109,9 @@ RSpec.describe Peek::Views::ActiveRecord, :request_store do
)
end
context 'when the multiple_database_metrics feature flag is disabled' do
context 'when the GITLAB_MULTIPLE_DATABASE_METRICS env var is disabled' do
before do
stub_feature_flags(multiple_database_metrics: false)
stub_env('GITLAB_MULTIPLE_DATABASE_METRICS', nil)
end
it 'does not include db_config_name field' do
......@@ -191,9 +191,9 @@ RSpec.describe Peek::Views::ActiveRecord, :request_store do
)
end
context 'when the multiple_database_metrics feature flag is disabled' do
context 'when the GITLAB_MULTIPLE_DATABASE_METRICS env var is disabled' do
before do
stub_feature_flags(multiple_database_metrics: false)
stub_env('GITLAB_MULTIPLE_DATABASE_METRICS', nil)
end
it 'does not include db_config_name field' do
......
# frozen_string_literal: true
RSpec.configure do |config|
config.before do
# Enable this by default in all tests so it behaves like a FF
stub_env('GITLAB_MULTIPLE_DATABASE_METRICS', '1')
end
end
......@@ -64,9 +64,9 @@ RSpec.shared_examples 'store ActiveRecord info in RequestStore' do |db_role|
end
end
context 'when multiple_database_metrics is disabled' do
context 'when the GITLAB_MULTIPLE_DATABASE_METRICS env var is disabled' do
before do
stub_feature_flags(multiple_database_metrics: false)
stub_env('GITLAB_MULTIPLE_DATABASE_METRICS', nil)
end
it 'does not include per database metrics' 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