Class: Gitlab::Metrics::Subscribers::RailsCache

Inherits:
ActiveSupport::Subscriber
  • Object
show all
Defined in:
lib/gitlab/metrics/subscribers/rails_cache.rb

Overview

Class for tracking the total time spent in Rails cache calls

Instance Method Summary collapse

Instance Method Details

#cache_delete(event) ⇒ Object


16
17
18
# File 'lib/gitlab/metrics/subscribers/rails_cache.rb', line 16

def cache_delete(event)
  increment(:cache_delete_duration, event.duration)
end

#cache_exist?(event) ⇒ Boolean


20
21
22
# File 'lib/gitlab/metrics/subscribers/rails_cache.rb', line 20

def cache_exist?(event)
  increment(:cache_exists_duration, event.duration)
end

#cache_read(event) ⇒ Object


8
9
10
# File 'lib/gitlab/metrics/subscribers/rails_cache.rb', line 8

def cache_read(event)
  increment(:cache_read_duration, event.duration)
end

#cache_write(event) ⇒ Object


12
13
14
# File 'lib/gitlab/metrics/subscribers/rails_cache.rb', line 12

def cache_write(event)
  increment(:cache_write_duration, event.duration)
end

#increment(key, duration) ⇒ Object


24
25
26
27
28
29
# File 'lib/gitlab/metrics/subscribers/rails_cache.rb', line 24

def increment(key, duration)
  return unless current_transaction

  current_transaction.increment(:cache_duration, duration)
  current_transaction.increment(key, duration)
end