Commit 90cca776 authored by Sean McGivern's avatar Sean McGivern

Memoise database load balancing status

This sampler runs every few seconds, and in development mode, it can
flood the console with license load messages. This value can only change
during the lifetime of the sampler if someone uploads a new license, or
a license expires, but those are both pretty rare (and would need
associated configuration changes anyway).
parent 14822a68
......@@ -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