Class: NewRelic::Agent::Instrumentation::ActionControllerOtherSubscriber

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

Instance Method Summary collapse

Methods inherited from NotificationsSubscriber

#define_exception_method, find_all_subscribers, #finish, #finish_segment, #initialize, #log_notification_error, #pop_segment, #push_segment, #segment_stack, #start, #start_segment, #state, subscribe, subscribed?

Constructor Details

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

Instance Method Details

#add_segment_params(segment, payload) ⇒ Object



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

def add_segment_params(segment, payload)
  segment.params[:filter] = payload[:filter] if payload[:filter]
  segment.params[:keys] = payload[:keys] if payload[:keys]
  segment.params[:original_path] = payload[:request].original_fullpath if payload[:request]

  if payload[:context]
    segment.params[:action] = payload[:context][:action]
    segment.params[:controller] = payload[:context][:controller]
  end
end

#controller_name_for_metric(payload) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb', line 29

def controller_name_for_metric(payload)
  return unless payload
  # redirect_to
  return payload[:request].controller_class.controller_path if payload[:request].respond_to?(:controller_class) && payload[:request].controller_class&.respond_to?(:controller_path)

  # unpermitted_parameters
  if payload[:context]&.[](:controller) && constantized_class = ::NewRelic::LanguageSupport.constantize(payload[:context][:controller])
    constantized_class.respond_to?(:controller_path) ? constantized_class.controller_path : nil
  end
end

#metric_name(name, payload) ⇒ Object



24
25
26
27
# File 'lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb', line 24

def metric_name(name, payload)
  controller_name = controller_name_for_metric(payload)
  "Ruby/ActionController#{"/#{controller_name}" if controller_name}/#{name.gsub('.action_controller', '')}"
end