Commit 0f4a3165 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'memoise-database-load-balancing-enabled-check' into 'master'

Memoise database load balancing status

Closes #218966

See merge request gitlab-org/gitlab!32964
parents e61fee0e 90cca776
......@@ -5,8 +5,12 @@ module EE
module Metrics
module Samplers
module DatabaseSampler
extend ::Gitlab::Utils::Override
include ::Gitlab::Utils::StrongMemoize
private
override :host_stats
def host_stats
super
.concat(geo_connection_stats)
......@@ -20,7 +24,7 @@ module EE
end
def load_balancing_connection_stats
return [] unless ::Gitlab::Database::LoadBalancing.enable?
return [] unless load_balancing_enabled?
ActiveRecord::Base.connection.load_balancer.host_list.hosts.map do |host|
{
......@@ -29,6 +33,12 @@ module EE
}
end
end
def load_balancing_enabled?
strong_memoize(:load_balancing_enabled) do
::Gitlab::Database::LoadBalancing.enable?
end
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