Class: NewRelic::Agent::Instrumentation::CustomEventsSubscriber

Inherits:
NotificationsSubscriber show all
Defined in:
lib/new_relic/agent/instrumentation/custom_events_subscriber.rb

Instance Method Summary collapse

Methods inherited from NotificationsSubscriber

#add_segment_params, #define_exception_method, find_all_subscribers, #finish_segment, #initialize, #log_notification_error, #metric_name, #pop_segment, #push_segment, #segment_stack, #start_segment, #state, subscribe, subscribed?

Constructor Details

This class inherits a constructor from NewRelic::Agent::Instrumentation::NotificationsSubscriber

Instance Method Details

#finish(name, id, payload) ⇒ Object

THREAD_LOCAL_ACCESS



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/new_relic/agent/instrumentation/custom_events_subscriber.rb', line 20

def finish(name, id, payload) # THREAD_LOCAL_ACCESS
  return unless state.is_execution_traced?

  NewRelic::Agent.notice_error(payload[:exception_object]) if payload.key?(:exception_object)

  finishable = pop_segment(id)
  # the following line needs else branch coverage
  finishable.finish if finishable # rubocop:disable Style/SafeNavigation
rescue => e
  log_notification_error(e, name, 'finish')
end

#start(name, id, _payload) ⇒ Object

THREAD_LOCAL_ACCESS



10
11
12
13
14
15
16
17
18
# File 'lib/new_relic/agent/instrumentation/custom_events_subscriber.rb', line 10

def start(name, id, _payload) # THREAD_LOCAL_ACCESS
  return unless state.is_execution_traced?

  finishable = NewRelic::Agent::Tracer.start_transaction_or_segment(name: transaction_name(name),
    category: :custom_events)
  push_segment(id, finishable)
rescue => e
  log_notification_error(e, name, 'start')
end