class SpeedGun::Profiler::ActiveSupportNotificatiosProfiler

Public Class Methods

backtrace() click to toggle source
# File lib/speed_gun/profiler/active_support_notifications_profiler.rb, line 26
def self.backtrace
  SpeedGun.get_backtrace(caller(2))
end
record(event, name, started, ended, _id, payload, ignore_payload) click to toggle source
# File lib/speed_gun/profiler/active_support_notifications_profiler.rb, line 12
def self.record(event, name, started, ended, _id, payload, ignore_payload)
  name = name.split('.').reverse.join('.')
  payload = payload.symbolize_keys

  ignore_payload.each do |key|
    payload.delete(key)
  end

  payload[:backtrace] = backtrace

  event = SpeedGun::Event.new(name, payload, started, ended)
  SpeedGun.record(event)
end
subscribe(event, ignore_payload = []) click to toggle source
# File lib/speed_gun/profiler/active_support_notifications_profiler.rb, line 5
def self.subscribe(event, ignore_payload = [])
  klass = self
  ActiveSupport::Notifications.subscribe(event) do |*args|
    klass.record(event, *args, ignore_payload)
  end
end