Commit 087c9a5e authored by Pawel Chojnacki's avatar Pawel Chojnacki

Fix rubocop warnings

parent 0325c237
...@@ -4,13 +4,13 @@ module Gitlab ...@@ -4,13 +4,13 @@ module Gitlab
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
@@_metrics_provider_mutex ||= Mutex.new @_metrics_provider_mutex ||= Mutex.new
@@_metrics_provider_cache ||= {} @_metrics_provider_cache ||= {}
end end
class_methods do class_methods do
def reload_metric!(name) def reload_metric!(name)
@@_metrics_provider_cache.delete(name) @_metrics_provider_cache.delete(name)
end end
private private
...@@ -22,7 +22,7 @@ module Gitlab ...@@ -22,7 +22,7 @@ module Gitlab
define_singleton_method(name) do define_singleton_method(name) do
# avoid unnecessary method call to speed up metric access # avoid unnecessary method call to speed up metric access
return @@_metrics_provider_cache[name] if @@_metrics_provider_cache.has_key?(name) return @_metrics_provider_cache[name] if @_metrics_provider_cache.has_key?(name)
fetch_metric(type, name, opts, &block) fetch_metric(type, name, opts, &block)
end end
...@@ -30,16 +30,16 @@ module Gitlab ...@@ -30,16 +30,16 @@ module Gitlab
def fetch_metric(type, name, opts = {}, &block) def fetch_metric(type, name, opts = {}, &block)
# avoid synchronization to speed up metrics access # avoid synchronization to speed up metrics access
return @@_metrics_provider_cache[name] if @@_metrics_provider_cache.has_key?(name) return @_metrics_provider_cache[name] if @_metrics_provider_cache.has_key?(name)
options = MetricOptions.new(opts) options = MetricOptions.new(opts)
options.evaluate(&block) options.evaluate(&block)
@@_metrics_provider_mutex.synchronize do @_metrics_provider_mutex.synchronize do
@@_metrics_provider_cache[name] ||= build_metric!(type, name, options) @_metrics_provider_cache[name] ||= build_metric!(type, name, options)
end end
@@_metrics_provider_cache[name] @_metrics_provider_cache[name]
end end
def build_metric!(type, name, options) def build_metric!(type, name, options)
...@@ -48,16 +48,16 @@ module Gitlab ...@@ -48,16 +48,16 @@ module Gitlab
end end
case type case type
when :gauge when :gauge
Gitlab::Metrics.gauge(name, options.docstring, options.base_labels, options.multiprocess_mode) Gitlab::Metrics.gauge(name, options.docstring, options.base_labels, options.multiprocess_mode)
when :counter when :counter
Gitlab::Metrics.counter(name, options.docstring, options.base_labels) Gitlab::Metrics.counter(name, options.docstring, options.base_labels)
when :histogram when :histogram
Gitlab::Metrics.histogram(name, options.docstring, options.base_labels, options.buckets) Gitlab::Metrics.histogram(name, options.docstring, options.base_labels, options.buckets)
when :summary when :summary
raise NotImplementedError, "summary metrics are not currently supported" raise NotImplementedError, "summary metrics are not currently supported"
else else
raise ArgumentError, "uknown metric type #{type}" raise ArgumentError, "uknown metric type #{type}"
end end
end end
......
...@@ -153,6 +153,7 @@ module Gitlab ...@@ -153,6 +153,7 @@ module Gitlab
fetch_metric(type, metric_name) do fetch_metric(type, metric_name) do
docstring "Transaction #{prefix}#{name} #{type}" docstring "Transaction #{prefix}#{name} #{type}"
base_labels tags.merge(BASE_LABELS) base_labels tags.merge(BASE_LABELS)
if type == :gauge if type == :gauge
multiprocess_mode :livesum multiprocess_mode :livesum
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