diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-09-05 02:34:28 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-11-02 20:10:57 +0300 |
commit | 3cc28601f37c11e444362495f27d39aee3d7aaca (patch) | |
tree | bb69bfc20e78d8725c8903ac0ead3f642ea7f09c /lib/gitlab/metrics/method_call.rb | |
parent | b6d75b29551e250f853b1a85919c677ecd85ac73 (diff) |
Cleanup sampling code and fix bug with samplers running without sleep
Diffstat (limited to 'lib/gitlab/metrics/method_call.rb')
-rw-r--r-- | lib/gitlab/metrics/method_call.rb | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/lib/gitlab/metrics/method_call.rb b/lib/gitlab/metrics/method_call.rb index 2c650a987f1..fb652cbeb4f 100644 --- a/lib/gitlab/metrics/method_call.rb +++ b/lib/gitlab/metrics/method_call.rb @@ -10,7 +10,7 @@ module Gitlab def self.call_real_duration_histogram @call_real_duration_histogram ||= Gitlab::Metrics.histogram(:gitlab_method_call_real_duration_milliseconds, 'Method calls real duration', - {}, + {call_name: nil}, [1, 2, 5, 10, 20, 50, 100, 1000]) end @@ -18,17 +18,16 @@ module Gitlab def self.call_cpu_duration_histogram @call_duration_histogram ||= Gitlab::Metrics.histogram(:gitlab_method_call_cpu_duration_milliseconds, 'Method calls cpu duration', - {}, + {call_name: nil}, [1, 2, 5, 10, 20, 50, 100, 1000]) end - def initialize(name, tags = {}) + def initialize(name) @name = name @real_time = 0 @cpu_time = 0 @call_count = 0 - @tags = tags end # Measures the real and CPU execution time of the supplied block. @@ -42,25 +41,13 @@ module Gitlab @call_count += 1 if above_threshold? - self.class.call_real_duration_histogram.observe(labels, @real_time) - self.class.call_cpu_duration_histogram.observe(labels, @cpu_time) + self.class.call_real_duration_histogram.observe({ call_name: @name }, @real_time) + self.class.call_cpu_duration_histogram.observe({ call_name: @name }, @cpu_time) end retval end - def labels - @labels ||= @tags.merge(source_label).merge({ call_name: @name }) - end - - def source_label - if Sidekiq.server? - { source: 'sidekiq' } - else - { source: 'rails' } - end - end - # Returns a Metric instance of the current method call. def to_metric Metric.new( |