class Tuttle::Instrumenter
Public Class Methods
initialize_tuttle_instrumenter()
click to toggle source
# File lib/tuttle/instrumenter.rb, line 10 def self.initialize_tuttle_instrumenter # For now, only instrument non-production mode 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 # Note: For Rails < 4.2 instrumentation is not enabled by default. # Hitting the cache inspector page will enable it for that session. 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