Sha256: 7e6c7197d8032a6c6c610943056648377324a9e666b575f43a229ef23913d59b

Contents?: true

Size: 1.79 KB

Versions: 20

Compression:

Stored size: 1.79 KB

Contents

# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

require 'new_relic/agent/instrumentation/notifications_subscriber'
require 'new_relic/agent/instrumentation/ignore_actions'
require 'new_relic/agent/parameter_filtering'

module NewRelic
  module Agent
    module Instrumentation
      class ActionControllerOtherSubscriber < NotificationsSubscriber
        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

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

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
newrelic_rpm-9.17.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.16.1 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.16.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.15.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.14.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.13.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.12.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.11.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.10.2 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.10.1 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.10.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.9.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.8.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.7.1 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.7.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.6.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.5.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.4.2 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.4.1 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
newrelic_rpm-9.4.0 lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb