Class: NewRelic::Agent::Instrumentation::ActionDispatchSubscriber
Constant Summary
collapse
- PATTERN =
/\A([^\.]+)\.action_dispatch\z/
- UNKNOWN =
'unknown'.freeze
- METHOD_NAME_MAPPING =
Hash.new do |h, k|
if PATTERN =~ k
h[k] = $1
else
h[k] = UNKNOWN
end
end
Instance Method Summary
collapse
#add_segment_params, #define_exception_method, find_all_subscribers, #initialize, #log_notification_error, #pop_segment, #push_segment, #segment_stack, #state, subscribe, subscribed?
Instance Method Details
#finish(name, id, payload) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb', line 19
def finish(name, id, payload)
return unless state.is_execution_traced?
finish_segment(id, payload)
rescue => e
log_notification_error(e, name, 'finish')
end
|
#finish_segment(id, payload) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb', line 32
def finish_segment(id, payload)
if segment = pop_segment(id)
if exception = exception_object(payload)
segment.notice_error(exception)
end
segment.finish
end
end
|
#method_from_name(name) ⇒ Object
58
59
60
|
# File 'lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb', line 58
def method_from_name(name)
METHOD_NAME_MAPPING[name]
end
|
#metric_name(name, payload) ⇒ Object
41
42
43
44
45
|
# File 'lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb', line 41
def metric_name(name, payload)
middleware = payload[:middleware]
method = method_from_name(name)
"Ruby/ActionDispatch/#{middleware}/#{method}"
end
|
#start(name, id, payload) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb', line 11
def start(name, id, payload)
return unless state.is_execution_traced?
start_segment(name, id, payload)
rescue => e
log_notification_error(e, name, 'start')
end
|
#start_segment(name, id, payload) ⇒ Object
27
28
29
30
|
# File 'lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb', line 27
def start_segment(name, id, payload)
segment = Tracer.start_segment(name: metric_name(name, payload))
push_segment(id, segment)
end
|