Class: BuilderApm::Controllers::Instrumenter

Inherits:
Object
  • Object
show all
Defined in:
lib/builder_apm/controllers/instrumenter.rb

Instance Method Summary collapse

Instance Method Details

#process_action(event) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/builder_apm/controllers/instrumenter.rb', line 27

def process_action(event)
  return if event.payload[:controller].start_with?("BuilderApm::")
  
  request_id = Thread.current[:request_id]
  Thread.current['request_data'] = extract_data_from_event(event)
ensure
  clean_up_thread_values
end

#process_start(event) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/builder_apm/controllers/instrumenter.rb', line 17

def process_start(event)
  return if event.payload[:controller].nil? # || event.payload[:controller].start_with?("BuilderApm::")

  uuid = event.payload[:headers].env['action_dispatch.request_id']
  Thread.current[:request_id] = uuid
  Thread.current[:stack] = [setup_controller_stack_data(event)]
  Thread.current[:method_tracing] = 0
  Thread.current[:db_tracing] = 0
end

#startObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/builder_apm/controllers/instrumenter.rb', line 5

def start
  ActiveSupport::Notifications.subscribe 'start_processing.action_controller' do |*args|
    event = event_from_args(*args)
    process_start(event)
  end

  ActiveSupport::Notifications.subscribe 'process_action.action_controller' do |*args|
    event = event_from_args(*args)
    process_action(event)
  end
end