Module NewRelic::Agent::MethodTracer::ClassMethods
In: lib/new_relic/agent/method_tracer.rb

Defines methods used at the class level, for adding instrumentation @api public

Methods

Included Modules

AddMethodTracer

Classes and Modules

Module NewRelic::Agent::MethodTracer::ClassMethods::AddMethodTracer

Public Instance methods

Add a method tracer to the specified method.

By default, this will cause invocations of the traced method to be recorded in transaction traces, and in a metric named after the class and method. It will also make the method show up in transaction-level breakdown charts and tables.

Overriding the metric name

metric_name_code is a string that is eval‘d to get the name of the metric associated with the call, so if you want to use interpolation evaluated at call time, then single quote the value like this:

    add_method_tracer :foo, 'Custom/#{self.class.name}/foo'

This would name the metric according to the class of the runtime intance, as opposed to the class where foo is defined.

If not provided, the metric name will be Custom/ClassName/method_name.

@param [Symbol] method_name the name of the method to trace @param [String] metric_name_code the metric name to record calls to

  the traced method under. This may be either a static string, or Ruby
  code to be evaluated at call-time in order to determine the metric
  name dynamically.

@param [Hash] options additional options controlling how the method is

  traced.

@option options [Boolean] :push_scope (true) If false, the traced method will

  not appear in transaction traces or breakdown charts, and it will
  only be visible in custom dashboards.

@option options [Boolean] :metric (true) If false, the traced method will

  only appear in transaction traces, but no metrics will be recorded
  for it.

@option options [String] :code_header (’’) Ruby code to be inserted and run

  before the tracer begins timing.

@option options [String] :code_footer (’’) Ruby code to be inserted and run

  after the tracer stops timing.

@example

  add_method_tracer :foo

  # With a custom metric name
  add_method_tracer :foo, 'Custom/#{self.class.name}/foo'

  # Instrument foo only for custom dashboards (not in transaction
  # traces or breakdown charts)
  add_method_tracer :foo, 'Custom/foo', :push_scope => false

  # Instrument foo in transaction traces only
  add_method_tracer :foo, 'Custom/foo', :metric => false

@api public

[Validate]