Module: NewRelic::Agent::MethodTracer::ClassMethods
- Included in:
- NewRelic::Agent::MethodTracer
- Defined in:
- lib/new_relic/agent/method_tracer.rb
Overview
Defines methods used at the class level, for adding instrumentation
Instance Method Summary collapse
-
#add_method_tracer(method_name, metric_name = nil, options = {}) ⇒ Object
Add a method tracer to the specified method.
Instance Method Details
#add_method_tracer(method_name, metric_name = nil, options = {}) ⇒ Object
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
is a String or Proc. If a Proc is given, it is bound to the object that called the traced method. For example:
add_method_tracer :foo, -> { "Custom/#{self.class.name}/foo" }
This would name the metric according to the class of the runtime instance, as opposed to the class where foo
is defined.
If not provided, the metric name will be Custom/ClassName/method_name
.
246 247 248 |
# File 'lib/new_relic/agent/method_tracer.rb', line 246 def add_method_tracer(method_name, metric_name = nil, = {}) ::NewRelic::Agent.add_or_defer_method_tracer(self, method_name, metric_name, ) end |