Class: TingYun::Instrumentation::Rails::ActionControllerSubscriber

Inherits:
Support::EventedSubscriber show all
Defined in:
lib/ting_yun/instrumentation/support/action_controller_subscriber.rb

Instance Method Summary collapse

Methods inherited from Support::EventedSubscriber

#event_stack, #initialize, #log_notification_error, #pop_event, #push_event, subscribe, subscribed?

Constructor Details

This class inherits a constructor from TingYun::Instrumentation::Support::EventedSubscriber

Instance Method Details

#finish(name, id, payload) ⇒ Object

THREAD_LOCAL_ACCESS



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ting_yun/instrumentation/support/action_controller_subscriber.rb', line 26

def finish(name, id, payload) #THREAD_LOCAL_ACCESS

  event = pop_event(id)
  event.payload.merge!(payload)

  state = TingYun::Agent::TransactionState.tl_get


  stop_transaction(state)
rescue => e
  log_notification_error(e, name, 'finish')
end

#start(name, id, payload) ⇒ Object

THREAD_LOCAL_ACCES



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ting_yun/instrumentation/support/action_controller_subscriber.rb', line 14

def start(name, id, payload) #THREAD_LOCAL_ACCES
  state = TingYun::Agent::TransactionState.tl_get
  request = state.current_transaction.request_attributes rescue nil
  event = ControllerEvent.new(name, Time.now, nil, id, payload, request)
  push_event(event)
  # if state.execution_traced?
  start_transaction(state, event)
    # end
rescue => e
  log_notification_error(e, name, 'start')
end

#start_transaction(state, event) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/ting_yun/instrumentation/support/action_controller_subscriber.rb', line 39

def start_transaction(state, event)
  params = TingYun::Instrumentation::Support::ParameterFiltering.flattened_filter_request_parameters(event.payload[:params])
  TingYun::Agent::Transaction.start(state, :controller,
                                    :request => event.request,
                                    :filtered_params => params,
                                    :apdex_start_time => event.queue_start,
                                    :transaction_name => event.metric_name)
end

#stop_transaction(state) ⇒ Object



48
49
50
51
# File 'lib/ting_yun/instrumentation/support/action_controller_subscriber.rb', line 48

def stop_transaction(state)
  # txn = state.current_transaction
  TingYun::Agent::Transaction.stop(state)
end