| Module | NewRelic::Agent::Instrumentation::ControllerInstrumentation |
| In: |
lib/new_relic/agent/instrumentation/controller_instrumentation.rb
|
This module can also be used to capture performance information for background tasks and other non-web transactions, including detailed transaction traces and traced errors.
For details on how to instrument background tasks see {ClassMethods#add_transaction_tracer} and {perform_action_with_newrelic_trace}
@api public
| NR_DO_NOT_TRACE_KEY | = | :'@do_not_trace' unless defined?(NR_DO_NOT_TRACE_KEY ) |
| NR_IGNORE_APDEX_KEY | = | :'@ignore_apdex' unless defined?(NR_IGNORE_APDEX_KEY ) |
| NR_IGNORE_ENDUSER_KEY | = | :'@ignore_enduser' unless defined?(NR_IGNORE_ENDUSER_KEY) |
| NR_DEFAULT_OPTIONS | = | {}.freeze unless defined?(NR_DEFAULT_OPTIONS ) |
Yield to the given block with NewRelic tracing. Used by default instrumentation on controller actions in Rails and Merb. But it can also be used in custom instrumentation of controller methods and background tasks.
This is the method invoked by instrumentation added by the ClassMethods#add_transaction_tracer.
Here‘s a more verbose version of the example shown in ClassMethods#add_transaction_tracer using this method instead of add_transaction_tracer.
Below is a controller with an invoke_operation action which dispatches to more specific operation methods based on a parameter (very dangerous, btw!). With this instrumentation, the invoke_operation action is ignored but the operation methods show up in New Relic as if they were first class controller actions
MyController < ActionController::Base
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
# dispatch the given op to the method given by the service parameter.
def invoke_operation
op = params['operation']
perform_action_with_newrelic_trace(:name => op) do
send op, params['message']
end
end
# Ignore the invoker to avoid double counting
newrelic_ignore :only => 'invoke_operation'
end
When invoking this method explicitly as in the example above, pass in a block to measure with some combination of options:
Seldomly used options:
@api public
overrideable method to determine whether to trace an action or not - you may override this in your controller and supply your own logic for ignoring transactions.