Class: NewRelic::Agent::Instrumentation::ActionViewSubscriber

Inherits:
EventedSubscriber show all
Defined in:
lib/new_relic/agent/instrumentation/action_view_subscriber.rb

Defined Under Namespace

Classes: RenderEvent

Instance Method Summary collapse

Methods inherited from EventedSubscriber

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

Constructor Details

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

Instance Method Details

#finish(name, id, payload) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/new_relic/agent/instrumentation/action_view_subscriber.rb', line 24

def finish(name, id, payload)
  event = pop_event(id)

  if NewRelic::Agent.is_execution_traced? && event.recordable?
    record_metrics(event)
    NewRelic::Agent.instance.stats_engine \
      .pop_scope(event.scope, event.metric_name, event.end)
  end
rescue => e
  log_notification_error(e, name, 'finish')
end

#record_metrics(event) ⇒ Object



36
37
38
39
40
41
# File 'lib/new_relic/agent/instrumentation/action_view_subscriber.rb', line 36

def record_metrics(event)
  NewRelic::Agent.instance.stats_engine \
    .record_metrics(event.metric_name,
                    event.duration,
                    :scoped => true)
end

#start(name, id, payload) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/new_relic/agent/instrumentation/action_view_subscriber.rb', line 12

def start(name, id, payload)
  event = RenderEvent.new(name, Time.now, nil, id, payload)
  push_event(event)

  if NewRelic::Agent.is_execution_traced? && event.recordable?
    event.scope = NewRelic::Agent.instance.stats_engine \
      .push_scope(:action_view, event.time)
  end
rescue => e
  log_notification_error(e, name, 'start')
end