Module NewRelic::Agent::Instrumentation::ControllerInstrumentation::ClassMethods
In: lib/new_relic/agent/instrumentation/controller_instrumentation.rb

@api public

Methods

Public Instance methods

Add transaction tracing to the given method. This will treat the given method as a main entrypoint for instrumentation, just like controller actions are treated by default. Useful especially for background tasks.

Example for background job:

  class Job
    include NewRelic::Agent::Instrumentation::ControllerInstrumentation
    def run(task)
       ...
    end
    # Instrument run so tasks show up under task.name.  Note single
    # quoting to defer eval to runtime.
    add_transaction_tracer :run, :name => '#{args[0].name}'
  end

Here‘s an example of a controller that uses a dispatcher action to invoke operations which you want treated as top level actions, so they aren‘t all lumped into the invoker action.

  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']
      send op
    end
    # Ignore the invoker to avoid double counting
    newrelic_ignore :only => 'invoke_operation'
    # Instrument the operations:
    add_transaction_tracer :print
    add_transaction_tracer :show
    add_transaction_tracer :forward
  end

Here‘s an example of how to pass contextual information into the transaction so it will appear in transaction traces:

  class Job
    include NewRelic::Agent::Instrumentation::ControllerInstrumentation
    def process(account)
       ...
    end
    # Include the account name in the transaction details.  Note the single
    # quotes to defer eval until call time.
    add_transaction_tracer :process, :params => '{ :account_name => args[0].name }'
  end

See NewRelic::Agent::Instrumentation::ControllerInstrumentation#perform_action_with_newrelic_trace for the full list of available options.

@api public

Have NewRelic ignore actions in this controller. Specify the actions as hash options using :except and :only. If no actions are specified, all actions are ignored.

@api public

Have NewRelic omit apdex measurements on the given actions. Typically used for actions that are not user facing or that skew your overall apdex measurement. Accepts :except and :only options, as with newrelic_ignore.

@api public

[Validate]