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: ...@@ -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 was sent to the read/write primary server. "Replica" means it was sent
to a read-only replica. to a read-only replica.
- **Config name**: shows up only when the - **Config name**: shows up only when the
`multiple_database_metrics` feature flag is enabled. This is used to `GITLAB_MULTIPLE_DATABASE_METRICS` environment variable is set. This is
distinguish between different databases configured for different GitLab used to distinguish between different databases configured for different
features. The name shown is the same name used to configure database GitLab features. The name shown is the same name used to configure database
connections in GitLab. connections in GitLab.
- **Gitaly calls**: the time taken (in milliseconds) and the total number of - **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 [Gitaly](../../gitaly/index.md) calls. Click to display a modal window with more
......
...@@ -175,7 +175,7 @@ module Gitlab ...@@ -175,7 +175,7 @@ module Gitlab
DB_LOAD_BALANCING_ROLES.each do |role| DB_LOAD_BALANCING_ROLES.each do |role|
metrics.each do |metric| metrics.each do |metric|
counters << compose_metric_key(metric, role) 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| ::Gitlab::Database.db_config_names.each do |config_name|
counters << compose_metric_key(metric, role, config_name) counters << compose_metric_key(metric, role, config_name)
......
...@@ -81,7 +81,7 @@ module Peek ...@@ -81,7 +81,7 @@ module Peek
end end
def format_call_details(call) def format_call_details(call)
if Feature.enabled?(:multiple_database_metrics, default_enabled: :yaml) if ENV['GITLAB_MULTIPLE_DATABASE_METRICS']
super super
else else
super.except(:db_config_name) super.except(:db_config_name)
......
...@@ -109,9 +109,9 @@ RSpec.describe Peek::Views::ActiveRecord, :request_store do ...@@ -109,9 +109,9 @@ RSpec.describe Peek::Views::ActiveRecord, :request_store do
) )
end 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 before do
stub_feature_flags(multiple_database_metrics: false) stub_env('GITLAB_MULTIPLE_DATABASE_METRICS', nil)
end end
it 'does not include db_config_name field' do it 'does not include db_config_name field' do
...@@ -191,9 +191,9 @@ RSpec.describe Peek::Views::ActiveRecord, :request_store do ...@@ -191,9 +191,9 @@ RSpec.describe Peek::Views::ActiveRecord, :request_store do
) )
end 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 before do
stub_feature_flags(multiple_database_metrics: false) stub_env('GITLAB_MULTIPLE_DATABASE_METRICS', nil)
end end
it 'does not include db_config_name field' do 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| ...@@ -64,9 +64,9 @@ RSpec.shared_examples 'store ActiveRecord info in RequestStore' do |db_role|
end end
end end
context 'when multiple_database_metrics is disabled' do context 'when the GITLAB_MULTIPLE_DATABASE_METRICS env var is disabled' do
before do before do
stub_feature_flags(multiple_database_metrics: false) stub_env('GITLAB_MULTIPLE_DATABASE_METRICS', nil)
end end
it 'does not include per database metrics' do 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