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
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2018-01-12 19:55:53 +0300
committerPawel Chojnacki <pawel@chojnacki.ws>2018-01-29 17:13:03 +0300
commitef44fef15f6cacc1f3ecb6ecd10a919004b57dae (patch)
tree75ecb4d40de3992b74d7e98929e1c2271a476438 /lib/gitlab/metrics/subscribers
parent51897df564db16726b452bdacf9eabe85b7c06f1 (diff)
Initiaal implementation of metrics concern
Diffstat (limited to 'lib/gitlab/metrics/subscribers')
-rw-r--r--lib/gitlab/metrics/subscribers/action_view.rb19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/gitlab/metrics/subscribers/action_view.rb b/lib/gitlab/metrics/subscribers/action_view.rb
index 3da474fc1ec..5c390a077c2 100644
--- a/lib/gitlab/metrics/subscribers/action_view.rb
+++ b/lib/gitlab/metrics/subscribers/action_view.rb
@@ -3,6 +3,11 @@ module Gitlab
module Subscribers
# Class for tracking the rendering timings of views.
class ActionView < ActiveSupport::Subscriber
+ include Gitlab::Metrics::Concern
+ histogram :gitlab_view_rendering_duration_seconds, 'View rendering time',
+ base_labels: Transaction::BASE_LABELS.merge({ path: nil }),
+ buckets: [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.500, 2.0, 10.0]
+
attach_to :action_view
SERIES = 'views'.freeze
@@ -15,23 +20,11 @@ module Gitlab
private
- def metric_view_rendering_duration_seconds
- @metric_view_rendering_duration_seconds ||= Gitlab::Metrics.histogram(
- :gitlab_view_rendering_duration_seconds,
- 'View rendering time',
- Transaction::BASE_LABELS.merge({ path: nil }),
- [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.500, 2.0, 10.0]
- )
- end
-
def track(event)
values = values_for(event)
tags = tags_for(event)
- metric_view_rendering_duration_seconds.observe(
- current_transaction.labels.merge(tags),
- event.duration
- )
+ gitlab_view_rendering_duration_seconds.observe(current_transaction.labels.merge(tags), event.duration)
current_transaction.increment(:view_duration, event.duration)
current_transaction.add_metric(SERIES, values, tags)