class TingYun::Instrumentation::Rails::ActionCableSubscriber

Constants

DOT_ACTION_CABLE
EMPTY_STRING
PERFORM_ACTION

Public Instance Methods

finish(name, id, payload) click to toggle source
# File lib/ting_yun/instrumentation/support/action_cable_subscriber.rb, line 27
def finish (name, id, payload) #THREAD_LOCAL_ACCESS
  state = TingYun::Agent::TransactionState.tl_get
  return unless state.execution_traced?
  event = super
  notice_error payload if payload.key? :exception
  if event.name == PERFORM_ACTION
    finish_transaction state
  else
    stop_recording_metrics state, event
  end
rescue => e
  log_notification_error e, name, 'finish'
end
start(name, id, payload) click to toggle source
# File lib/ting_yun/instrumentation/support/action_cable_subscriber.rb, line 14
def start (name, id, payload) #THREAD_LOCAL_ACCESS
  state = TingYun::Agent::TransactionState.tl_get
  return unless state.execution_traced?
  event = super
  if event.name == PERFORM_ACTION
    start_transaction state, event
  else
    start_recording_metrics state, event
  end
rescue => e
  log_notification_error e, name, 'start'
end

Private Instance Methods

action_name_from_event(event) click to toggle source
# File lib/ting_yun/instrumentation/support/action_cable_subscriber.rb, line 73
def action_name_from_event event
  event.name.gsub DOT_ACTION_CABLE, EMPTY_STRING
end
finish_transaction(state) click to toggle source
# File lib/ting_yun/instrumentation/support/action_cable_subscriber.rb, line 47
def finish_transaction state
  TingYun::Agent::Transaction.stop(state)
end
metric_name_from_event(event) click to toggle source
# File lib/ting_yun/instrumentation/support/action_cable_subscriber.rb, line 66
def metric_name_from_event event
  "ActionCable/#{event.payload[:channel_class]}/#{action_name_from_event(event)}"
end
notice_error(payload) click to toggle source
# File lib/ting_yun/instrumentation/support/action_cable_subscriber.rb, line 77
def notice_error payload
  TingYun::Agent.notice_error payload[:exception_object]
end
start_recording_metrics(state, event) click to toggle source
# File lib/ting_yun/instrumentation/support/action_cable_subscriber.rb, line 51
def start_recording_metrics state, event
  expected_scope = TingYun::Agent::MethodTracerHelpers::trace_execution_scoped_header(state, event.time.to_f)
  event.payload[:expected_scope] =  expected_scope
end
start_transaction(state, event) click to toggle source
# File lib/ting_yun/instrumentation/support/action_cable_subscriber.rb, line 43
def start_transaction state, event
  TingYun::Agent::Transaction.start(state, :action_cable, :transaction_name => transaction_name_from_event(event))
end
stop_recording_metrics(state, event) click to toggle source
# File lib/ting_yun/instrumentation/support/action_cable_subscriber.rb, line 56
def stop_recording_metrics state, event
  expected_scope = event.payload.delete :expected_scope
  metric_name = metric_name_from_event event
  TingYun::Agent::MethodTracerHelpers::trace_execution_scoped_footer(state, event.time.to_f, metric_name, [], expected_scope, {:metric => true}, event.end.to_f)
end
transaction_name_from_event(event) click to toggle source
# File lib/ting_yun/instrumentation/support/action_cable_subscriber.rb, line 62
def transaction_name_from_event event
  "WebAction/ActionCable/#{event.payload[:channel_class]}/#{event.payload[:action]}"
end