10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/tuttle/instrumenter.rb', line 10
def self.initialize_tuttle_instrumenter
unless Rails.env.production?
ActiveSupport::Notifications.subscribe(/.*/) do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
Tuttle::Instrumenter.events << event
Tuttle::Instrumenter.event_counts[event.name] += 1
end
end
Tuttle::Engine.logger.info('Initializing cache_read subscriber')
ActiveSupport::Notifications.subscribe('cache_read.active_support') do |*args|
app_path = Rails.root.join('app').to_s
cache_call_location = caller_locations.detect { |cl| cl.path.start_with?(app_path) }
event = ActiveSupport::Notifications::Event.new(*args)
Tuttle::Engine.logger.info("Cache Read called: #{cache_call_location.path} on line #{cache_call_location.lineno} :: #{event.payload.inspect}")
event.payload.merge!(:call_location_path => cache_call_location.path, :call_location_lineno => cache_call_location.lineno)
Tuttle::Instrumenter.cache_events << event
end
ActiveSupport::Notifications.subscribe('cache_generate.active_support') do
Tuttle::Engine.logger.info('Cache Generate called')
end
end
|