diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2018-01-22 18:43:22 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2018-01-29 17:13:05 +0300 |
commit | b1ba8eb9a20ee7fad6948799dc0b96ad34a0f0be (patch) | |
tree | ccc1872f251ca7ab6c55aa735bf161f03e10de53 /lib | |
parent | 1ac96603e167a67ce8a69c17624625d3b2fd3400 (diff) |
Do not use include Gitlab::CurrentSettings unnecessarily
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/metrics/influx_db.rb | 24 | ||||
-rw-r--r-- | lib/gitlab/metrics/prometheus.rb | 4 |
2 files changed, 15 insertions, 13 deletions
diff --git a/lib/gitlab/metrics/influx_db.rb b/lib/gitlab/metrics/influx_db.rb index 3789787d796..e640ddbc716 100644 --- a/lib/gitlab/metrics/influx_db.rb +++ b/lib/gitlab/metrics/influx_db.rb @@ -13,8 +13,6 @@ module Gitlab private_constant :MUTEX class_methods do - include Gitlab::CurrentSettings - def influx_metrics_enabled? settings[:enabled] || false end @@ -22,16 +20,20 @@ module Gitlab # Prometheus histogram buckets used for arbitrary code measurements def settings - @settings ||= { - enabled: current_application_settings[:metrics_enabled], - pool_size: current_application_settings[:metrics_pool_size], - timeout: current_application_settings[:metrics_timeout], - method_call_threshold: current_application_settings[:metrics_method_call_threshold], - host: current_application_settings[:metrics_host], - port: current_application_settings[:metrics_port], - sample_interval: current_application_settings[:metrics_sample_interval] || 15, - packet_size: current_application_settings[:metrics_packet_size] || 1 + @settings ||= begin + current_settings = Gitlab::CurrentSettings.current_application_settings + + { + enabled: current_settings[:metrics_enabled], + pool_size: current_settings[:metrics_pool_size], + timeout: current_settings[:metrics_timeout], + method_call_threshold: current_settings[:metrics_method_call_threshold], + host: current_settings[:metrics_host], + port: current_settings[:metrics_port], + sample_interval: current_settings[:metrics_sample_interval] || 15, + packet_size: current_settings[:metrics_packet_size] || 1 } + end end def mri? diff --git a/lib/gitlab/metrics/prometheus.rb b/lib/gitlab/metrics/prometheus.rb index 9c645ad6af4..f07ea3560ff 100644 --- a/lib/gitlab/metrics/prometheus.rb +++ b/lib/gitlab/metrics/prometheus.rb @@ -9,7 +9,6 @@ module Gitlab PROVIDER_MUTEX = Mutex.new class_methods do - include Gitlab::CurrentSettings include Gitlab::Utils::StrongMemoize def metrics_folder_present? @@ -72,7 +71,8 @@ module Gitlab end def prometheus_metrics_enabled_unmemoized - metrics_folder_present? && current_application_settings[:prometheus_metrics_enabled] || false + metrics_folder_present? && + Gitlab::CurrentSettings.current_application_settings[:prometheus_metrics_enabled] || false end end end |