Class: SpeedGun::Profiler::ActiveSupportNotificatiosProfiler

Inherits:
SpeedGun::Profiler show all
Defined in:
lib/speed_gun/profiler/active_support_notifications_profiler.rb

Class Method Summary collapse

Methods inherited from SpeedGun::Profiler

ignore?, profile, #profile

Class Method Details

.backtraceObject



26
27
28
# 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) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# 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 = []) ⇒ Object



5
6
7
8
9
10
# 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