Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2018-01-22 13:55:36 +0300
committerPawel Chojnacki <pawel@chojnacki.ws>2018-01-29 17:13:04 +0300
commit938d9ffe40c7eca26703f25534c500339988acfb (patch)
tree2784ab0d915183b3a36472cab4a83b09413e3d3a /lib
parent7d716cc849ca5435cd5c038bdf924d5a995b6b93 (diff)
Refactor metrics to use metrics dsl notation
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/metrics/method_call.rb11
-rw-r--r--lib/gitlab/metrics/subscribers/action_view.rb11
-rw-r--r--lib/gitlab/metrics/transaction.rb22
3 files changed, 24 insertions, 20 deletions
diff --git a/lib/gitlab/metrics/method_call.rb b/lib/gitlab/metrics/method_call.rb
index 7cb153237d4..b0a37b8a4eb 100644
--- a/lib/gitlab/metrics/method_call.rb
+++ b/lib/gitlab/metrics/method_call.rb
@@ -8,11 +8,12 @@ module Gitlab
BASE_LABELS = { module: nil, method: nil }.freeze
attr_reader :real_time, :cpu_time, :call_count, :labels
- define_histogram :gitlab_method_call_duration_seconds,
- docstring: 'Method calls real duration',
- base_labels: Transaction::BASE_LABELS.merge(BASE_LABELS),
- buckets: [0.01, 0.05, 0.1, 0.5, 1],
- with_feature: :prometheus_metrics_method_instrumentation
+ define_histogram :gitlab_method_call_duration_seconds do
+ docstring 'Method calls real duration'
+ base_labels Transaction::BASE_LABELS.merge(BASE_LABELS)
+ buckets [0.01, 0.05, 0.1, 0.5, 1]
+ with_feature :prometheus_metrics_method_instrumentation
+ end
# name - The full name of the method (including namespace) such as
# `User#sign_in`.
diff --git a/lib/gitlab/metrics/subscribers/action_view.rb b/lib/gitlab/metrics/subscribers/action_view.rb
index 2e3beb05294..86bd56ff7eb 100644
--- a/lib/gitlab/metrics/subscribers/action_view.rb
+++ b/lib/gitlab/metrics/subscribers/action_view.rb
@@ -4,11 +4,12 @@ module Gitlab
# Class for tracking the rendering timings of views.
class ActionView < ActiveSupport::Subscriber
include Gitlab::Metrics::Concern
- define_histogram :gitlab_view_rendering_duration_seconds,
- docstring: 'View rendering time',
- base_labels: Transaction::BASE_LABELS.merge({ path: nil }),
- buckets: [0.001, 0.01, 0.1, 10.0],
- with_feature: :prometheus_metrics_view_instrumentation
+ define_histogram :gitlab_view_rendering_duration_seconds do
+ docstring 'View rendering time'
+ base_labels Transaction::BASE_LABELS.merge({ path: nil })
+ buckets [0.001, 0.01, 0.1, 10.0]
+ with_feature :prometheus_metrics_view_instrumentation
+ end
attach_to :action_view
diff --git a/lib/gitlab/metrics/transaction.rb b/lib/gitlab/metrics/transaction.rb
index ed5a2cec935..c4b6c376e40 100644
--- a/lib/gitlab/metrics/transaction.rb
+++ b/lib/gitlab/metrics/transaction.rb
@@ -137,16 +137,18 @@ module Gitlab
"#{labels[:controller]}##{labels[:action]}" if labels && !labels.empty?
end
- define_histogram :gitlab_transaction_duration_seconds,
- docstring: 'Transaction duration',
- base_labels: BASE_LABELS,
- buckets: [0.001, 0.01, 0.1, 0.5, 10.0]
-
- define_histogram :gitlab_transaction_allocated_memory_bytes,
- docstring: 'Transaction allocated memory bytes',
- base_labels: BASE_LABELS,
- buckets: [100, 1000, 10000, 100000, 1000000, 10000000],
- with_feature: :prometheus_metrics_transaction_allocated_memory
+ define_histogram :gitlab_transaction_duration_seconds do
+ docstring 'Transaction duration'
+ base_labels BASE_LABELS
+ buckets [0.001, 0.01, 0.1, 0.5, 10.0]
+ end
+
+ define_histogram :gitlab_transaction_allocated_memory_bytes do
+ docstring 'Transaction allocated memory bytes'
+ base_labels BASE_LABELS
+ buckets [100, 1000, 10000, 100000, 1000000, 10000000]
+ with_feature :prometheus_metrics_transaction_allocated_memory
+ end
def self.transaction_metric(name, type, prefix: nil, tags: {})
metric_name = "gitlab_transaction_#{prefix}#{name}_total".to_sym