Module: NewRelic::Agent::MethodTracer::InstanceMethods
- Includes:
- TraceExecutionScoped
- Defined in:
- lib/new_relic/agent/method_tracer.rb
Overview
Defines modules used at instrumentation runtime, to do the actual tracing of time spent
Defined Under Namespace
Modules: TraceExecutionScoped
Instance Method Summary collapse
-
#trace_execution_unscoped(metric_names, options = {}) ⇒ Object
(also: #trace_method_execution_no_scope)
Trace a given block with stats assigned to the given metric_name.
-
#trace_method_execution(metric_names, push_scope, produce_metric, deduct_call_time_from_parent, &block) ⇒ Object
Deprecated: original method preserved for API backward compatibility.
-
#trace_method_execution_with_scope(metric_names, produce_metric, deduct_call_time_from_parent, scoped_metric_only = false, &block) ⇒ Object
Deprecated.
Methods included from TraceExecutionScoped
#agent_instance, #get_metric_stats, #get_stats_scoped, #get_stats_unscoped, #log_errors, #main_stat, #pop_flag!, #push_flag!, #set_if_nil, #stat_engine, #trace_disabled?, #trace_execution_scoped, #trace_execution_scoped_footer, #trace_execution_scoped_header, #traced?
Instance Method Details
#trace_execution_unscoped(metric_names, options = {}) ⇒ Object Also known as: trace_method_execution_no_scope
Trace a given block with stats assigned to the given metric_name. It does not provide scoped measurements, meaning whatever is being traced will not ‘blame the Controller’–that is to say appear in the breakdown chart. This is code is inlined in #add_method_tracer.
-
metric_names
is a single name or an array of names of metrics -
:force => true
will force the metric to be captured even when tracing is disabled with NewRelic::Agent#disable_all_tracing
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/new_relic/agent/method_tracer.rb', line 70 def trace_execution_unscoped(metric_names, ={}) return yield unless NewRelic::Agent.is_execution_traced? t0 = Time.now stats = Array(metric_names).map do | metric_name | NewRelic::Agent.instance.stats_engine.get_stats_no_scope metric_name end begin NewRelic::Agent.instance.push_trace_execution_flag(true) if [:force] yield ensure NewRelic::Agent.instance.pop_trace_execution_flag if [:force] duration = (Time.now - t0).to_f # for some reason this is 3 usec faster than Time - Time stats.each { |stat| stat.trace_call(duration) } end end |
#trace_method_execution(metric_names, push_scope, produce_metric, deduct_call_time_from_parent, &block) ⇒ Object
Deprecated: original method preserved for API backward compatibility. Use either #trace_execution_scoped or #trace_execution_unscoped
53 54 55 56 57 58 59 60 |
# File 'lib/new_relic/agent/method_tracer.rb', line 53 def trace_method_execution(metric_names, push_scope, produce_metric, deduct_call_time_from_parent, &block) #:nodoc: if push_scope trace_execution_scoped(metric_names, :metric => produce_metric, :deduct_call_time_from_parent => deduct_call_time_from_parent, &block) else trace_execution_unscoped(metric_names, &block) end end |
#trace_method_execution_with_scope(metric_names, produce_metric, deduct_call_time_from_parent, scoped_metric_only = false, &block) ⇒ Object
Deprecated. Use #trace_execution_scoped, a version with an options hash.
87 88 89 90 91 92 |
# File 'lib/new_relic/agent/method_tracer.rb', line 87 def trace_method_execution_with_scope(metric_names, produce_metric, deduct_call_time_from_parent, scoped_metric_only=false, &block) #:nodoc: trace_execution_scoped(metric_names, :metric => produce_metric, :deduct_call_time_from_parent => deduct_call_time_from_parent, :scoped_metric_only => scoped_metric_only, &block) end |