-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1744 from newrelic/action_controller_subscriber_a…
…dditional_topic Subscribe to additional Action controller topics
- Loading branch information
Showing
20 changed files
with
354 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# 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) | ||
# redirect_to | ||
return payload[:request].controller_class.controller_path if payload[:request] && payload[:request].controller_class | ||
|
||
# unpermitted_parameters | ||
::NewRelic::LanguageSupport.constantize(payload[:context][:controller]).controller_path if payload[:context] && payload[:context][:controller] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.