Commit 7f91483e authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'remove-GITLAB_MULTIPLE_DATABASE_METRICS-env' into 'master'

Remove `GITLAB_MULTIPLE_DATABASE_METRICS` environment variable

See merge request gitlab-org/gitlab!82986
parents 7dd71a09 36331436
...@@ -30,8 +30,7 @@ From left to right, the performance bar displays: ...@@ -30,8 +30,7 @@ From left to right, the performance bar displays:
is enabled. It shows which server role was used for the query. is enabled. It shows which server role was used for the query.
"Primary" means that the query was sent to the read/write primary server. "Primary" means that the query was sent to the read/write primary server.
"Replica" means it was sent to a read-only replica. "Replica" means it was sent to a read-only replica.
- **Configuration name**: shows up only when the - **Configuration name**: this is
`GITLAB_MULTIPLE_DATABASE_METRICS` environment variable is set. This is
used to distinguish between different databases configured for different used to distinguish between different databases configured for different
GitLab 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.
......
...@@ -134,11 +134,7 @@ module Gitlab ...@@ -134,11 +134,7 @@ module Gitlab
:"gitlab_transaction_db_#{counter}_total" :"gitlab_transaction_db_#{counter}_total"
end end
if ENV['GITLAB_MULTIPLE_DATABASE_METRICS'] current_transaction&.increment(prometheus_key, 1, { db_config_name: db_config_name })
current_transaction&.increment(prometheus_key, 1, { db_config_name: db_config_name })
else
current_transaction&.increment(prometheus_key, 1)
end
Gitlab::SafeRequestStore[log_key] = Gitlab::SafeRequestStore[log_key].to_i + 1 Gitlab::SafeRequestStore[log_key] = Gitlab::SafeRequestStore[log_key].to_i + 1
...@@ -154,11 +150,7 @@ module Gitlab ...@@ -154,11 +150,7 @@ module Gitlab
def observe(histogram, event, &block) def observe(histogram, event, &block)
db_config_name = db_config_name(event.payload) db_config_name = db_config_name(event.payload)
if ENV['GITLAB_MULTIPLE_DATABASE_METRICS'] current_transaction&.observe(histogram, event.duration / 1000.0, { db_config_name: db_config_name }, &block)
current_transaction&.observe(histogram, event.duration / 1000.0, { db_config_name: db_config_name }, &block)
else
current_transaction&.observe(histogram, event.duration / 1000.0, &block)
end
end end
def current_transaction def current_transaction
...@@ -193,11 +185,9 @@ module Gitlab ...@@ -193,11 +185,9 @@ module Gitlab
counters << compose_metric_key(metric, role) counters << compose_metric_key(metric, role)
end end
if 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, nil, config_name) # main
counters << compose_metric_key(metric, nil, config_name) # main counters << compose_metric_key(metric, nil, config_name + ::Gitlab::Database::LoadBalancing::LoadBalancer::REPLICA_SUFFIX) # main_replica
counters << compose_metric_key(metric, nil, config_name + ::Gitlab::Database::LoadBalancing::LoadBalancer::REPLICA_SUFFIX) # main_replica
end
end end
end end
......
...@@ -75,14 +75,6 @@ module Peek ...@@ -75,14 +75,6 @@ module Peek
"Role: #{role.to_s.capitalize}" "Role: #{role.to_s.capitalize}"
end end
def format_call_details(call)
if ENV['GITLAB_MULTIPLE_DATABASE_METRICS']
super
else
super.except(:db_config_name)
end
end
end end
end end
end end
...@@ -119,16 +119,4 @@ RSpec.describe Peek::Views::ActiveRecord, :request_store do ...@@ -119,16 +119,4 @@ RSpec.describe Peek::Views::ActiveRecord, :request_store do
) )
) )
end end
context 'when the GITLAB_MULTIPLE_DATABASE_METRICS env var is disabled' do
before do
stub_env('GITLAB_MULTIPLE_DATABASE_METRICS', nil)
end
it 'does not include db_config_name field' do
ActiveSupport::Notifications.publish('sql.active_record', Time.current, Time.current + 1.second, '1', event_1)
expect(subject.results[:details][0][:db_config_name]).to be_nil
end
end
end end
# 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
...@@ -91,21 +91,6 @@ RSpec.shared_examples 'store ActiveRecord info in RequestStore' do |db_role| ...@@ -91,21 +91,6 @@ RSpec.shared_examples 'store ActiveRecord info in RequestStore' do |db_role|
end end
end end
end end
context 'when the GITLAB_MULTIPLE_DATABASE_METRICS env var is disabled' do
before do
stub_env('GITLAB_MULTIPLE_DATABASE_METRICS', nil)
end
it 'does not include per database metrics' do
Gitlab::WithRequestStore.with_request_store do
subscriber.sql(event)
expect(described_class.db_counter_payload).not_to include(:"db_replica_#{db_config_name}_duration_s")
expect(described_class.db_counter_payload).not_to include(:"db_replica_#{db_config_name}_count")
end
end
end
end end
RSpec.shared_examples 'record ActiveRecord metrics in a metrics transaction' do |db_role| RSpec.shared_examples 'record ActiveRecord metrics in a metrics transaction' do |db_role|
...@@ -160,26 +145,6 @@ RSpec.shared_examples 'record ActiveRecord metrics in a metrics transaction' do ...@@ -160,26 +145,6 @@ RSpec.shared_examples 'record ActiveRecord metrics in a metrics transaction' do
subscriber.sql(event) subscriber.sql(event)
end end
context 'when the GITLAB_MULTIPLE_DATABASE_METRICS env var is disabled' do
before do
stub_env('GITLAB_MULTIPLE_DATABASE_METRICS', nil)
end
it 'does not include db_config_name label' do
allow(transaction).to receive(:increment) do |*args|
labels = args[2] || {}
expect(labels).not_to include(:db_config_name)
end
allow(transaction).to receive(:observe) do |*args|
labels = args[2] || {}
expect(labels).not_to include(:db_config_name)
end
subscriber.sql(event)
end
end
end end
RSpec.shared_examples 'record ActiveRecord metrics' do |db_role| RSpec.shared_examples 'record ActiveRecord metrics' do |db_role|
......
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