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, #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



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

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
end

#record_metrics(event) ⇒ Object



32
33
34
35
36
37
# File 'lib/new_relic/agent/instrumentation/action_view_subscriber.rb', line 32

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
# 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
end