diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-10-24 10:09:13 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-11-02 20:18:16 +0300 |
commit | 67b3e3d84a66b60c8633ef9f4fa6ba5239cb36f6 (patch) | |
tree | 7d67bca6b4d70d4049b4570162153e7276829c01 /lib/gitlab/middleware | |
parent | 735365a367add91790e8e00a44b78f9933622c6b (diff) |
move metrics for ActiveRecord, RailsCache and queue duration to instance variables
Diffstat (limited to 'lib/gitlab/middleware')
-rw-r--r-- | lib/gitlab/middleware/rails_queue_duration.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/gitlab/middleware/rails_queue_duration.rb b/lib/gitlab/middleware/rails_queue_duration.rb index e92f1835e20..bc70b2459ef 100644 --- a/lib/gitlab/middleware/rails_queue_duration.rb +++ b/lib/gitlab/middleware/rails_queue_duration.rb @@ -5,13 +5,6 @@ module Gitlab module Middleware class RailsQueueDuration - def self.metric_rails_queue_duration_seconds - @metric_rails_queue_duration_seconds ||= Gitlab::Metrics.histogram( - :gitlab_rails_queue_duration_seconds, - Gitlab::Metrics::Transaction::BASE_LABELS - ) - end - def initialize(app) @app = app end @@ -23,11 +16,20 @@ module Gitlab # Time in milliseconds since gitlab-workhorse started the request duration = Time.now.to_f * 1_000 - proxy_start.to_f / 1_000_000 trans.set(:rails_queue_duration, duration) - self.class.metric_rails_queue_duration_seconds.observe(trans.labels, duration / 1_000) + metric_rails_queue_duration_seconds.observe(trans.labels, duration / 1_000) end @app.call(env) end + + private + + def metric_rails_queue_duration_seconds + @metric_rails_queue_duration_seconds ||= Gitlab::Metrics.histogram( + :gitlab_rails_queue_duration_seconds, + Gitlab::Metrics::Transaction::BASE_LABELS + ) + end end end end |