diff options
| author | Douwe Maan <douwe@gitlab.com> | 2017-11-24 09:01:12 +0000 |
|---|---|---|
| committer | Douwe Maan <douwe@gitlab.com> | 2017-11-24 09:01:12 +0000 |
| commit | fad4ab7d56ea1deb415adff541212ae901e31fd4 (patch) | |
| tree | beb536056a2d8809a13ccf6dda7270aa1c8eedf0 /lib | |
| parent | cf631ddbdceec49579a658698f11679a29cea579 (diff) | |
| parent | 46cd2d93bb23807b76bf20bb06e6ef93f1985ad9 (diff) | |
| download | gitlab-ce-fad4ab7d56ea1deb415adff541212ae901e31fd4.tar.gz | |
Merge branch 'pawel/update_prometheus_gem_to_well_tested_version' into 'master'
Update Prometheus Gem version and disable Prometheus method call instrumentation by default.
Closes gitlab-ee#4139 and #40457
See merge request gitlab-org/gitlab-ce!15558
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab/metrics/method_call.rb | 33 | ||||
| -rw-r--r-- | lib/gitlab/metrics/prometheus.rb | 6 |
2 files changed, 15 insertions, 24 deletions
diff --git a/lib/gitlab/metrics/method_call.rb b/lib/gitlab/metrics/method_call.rb index 90235095306..65d55576ac2 100644 --- a/lib/gitlab/metrics/method_call.rb +++ b/lib/gitlab/metrics/method_call.rb @@ -6,29 +6,15 @@ module Gitlab BASE_LABELS = { module: nil, method: nil }.freeze attr_reader :real_time, :cpu_time, :call_count, :labels - def self.call_real_duration_histogram - return @call_real_duration_histogram if @call_real_duration_histogram - - MUTEX.synchronize do - @call_real_duration_histogram ||= Gitlab::Metrics.histogram( - :gitlab_method_call_real_duration_seconds, - 'Method calls real duration', - Transaction::BASE_LABELS.merge(BASE_LABELS), - [0.1, 0.2, 0.5, 1, 2, 5, 10] - ) - end - end - - def self.call_cpu_duration_histogram - return @call_cpu_duration_histogram if @call_cpu_duration_histogram + def self.call_duration_histogram + return @call_duration_histogram if @call_duration_histogram MUTEX.synchronize do @call_duration_histogram ||= Gitlab::Metrics.histogram( - :gitlab_method_call_cpu_duration_seconds, - 'Method calls cpu duration', + :gitlab_method_call_duration_seconds, + 'Method calls real duration', Transaction::BASE_LABELS.merge(BASE_LABELS), - [0.1, 0.2, 0.5, 1, 2, 5, 10] - ) + [0.01, 0.05, 0.1, 0.5, 1]) end end @@ -59,8 +45,9 @@ module Gitlab @cpu_time += cpu_time @call_count += 1 - self.class.call_real_duration_histogram.observe(@transaction.labels.merge(labels), real_time / 1000.0) - self.class.call_cpu_duration_histogram.observe(@transaction.labels.merge(labels), cpu_time / 1000.0) + if call_measurement_enabled? && above_threshold? + self.class.call_duration_histogram.observe(@transaction.labels.merge(labels), real_time / 1000.0) + end retval end @@ -83,6 +70,10 @@ module Gitlab def above_threshold? real_time >= Metrics.method_call_threshold end + + def call_measurement_enabled? + Feature.get(:prometheus_metrics_method_instrumentation).enabled? + end end end end diff --git a/lib/gitlab/metrics/prometheus.rb b/lib/gitlab/metrics/prometheus.rb index 4f165d12a94..09103b4ca2d 100644 --- a/lib/gitlab/metrics/prometheus.rb +++ b/lib/gitlab/metrics/prometheus.rb @@ -17,9 +17,9 @@ module Gitlab end def prometheus_metrics_enabled? - # force disable prometheus_metrics until - # https://gitlab.com/gitlab-org/prometheus-client-mmap/merge_requests/11 is ready - false + return @prometheus_metrics_enabled if defined?(@prometheus_metrics_enabled) + + @prometheus_metrics_enabled = prometheus_metrics_enabled_unmemoized end def registry |
