summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaco Guzman <pacoguzmanp@gmail.com>2016-06-29 17:03:20 +0200
committerPaco Guzman <pacoguzmanp@gmail.com>2016-07-05 12:28:06 +0200
commit330de255b75fa7b9897844582b8fd7e020f4efa7 (patch)
treed8ec783d7b842e9d0523093553190b25349132f8 /lib
parente9a4d117f2fb6f10af3357a8a6591ba7022d9c62 (diff)
downloadgitlab-ce-330de255b75fa7b9897844582b8fd7e020f4efa7.tar.gz
RailsCache metrics now includes fetch_hit/fetch_miss and read_hit/read_miss info.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/metrics/subscribers/rails_cache.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/gitlab/metrics/subscribers/rails_cache.rb b/lib/gitlab/metrics/subscribers/rails_cache.rb
index 277c860fbef..aaed2184f44 100644
--- a/lib/gitlab/metrics/subscribers/rails_cache.rb
+++ b/lib/gitlab/metrics/subscribers/rails_cache.rb
@@ -2,11 +2,21 @@ module Gitlab
module Metrics
module Subscribers
# Class for tracking the total time spent in Rails cache calls
+ # http://guides.rubyonrails.org/active_support_instrumentation.html
class RailsCache < ActiveSupport::Subscriber
attach_to :active_support
def cache_read(event)
increment(:cache_read, event.duration)
+
+ return unless current_transaction
+ return if event.payload[:super_operation] == :fetch
+
+ if event.payload[:hit]
+ current_transaction.increment(:cache_read_hit_count, 1)
+ else
+ current_transaction.increment(:cache_read_miss_count, 1)
+ end
end
def cache_write(event)
@@ -24,13 +34,13 @@ module Gitlab
def cache_fetch_hit(event)
return unless current_transaction
- current_transaction.increment(:cache_fetch_hit, 1)
+ current_transaction.increment(:cache_read_hit_count, 1)
end
def cache_generate(event)
return unless current_transaction
- current_transaction.increment(:cache_fetch_miss, 1)
+ current_transaction.increment(:cache_read_miss_count, 1)
end
def increment(key, duration)