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

Methods included from TraceExecutionScoped

#agent_instance, #get_stats_scoped, #get_stats_unscoped, #has_parent?, #in_transaction?, #log_errors, #metrics_for_current_transaction, #metrics_for_parent_transaction, #pop_flag!, #push_flag!, #record_metrics, #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



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/new_relic/agent/method_tracer.rb', line 74

def trace_execution_unscoped(metric_names, options={})
  return yield unless NewRelic::Agent.is_execution_traced?
  t0 = Time.now
  begin
    NewRelic::Agent.instance.push_trace_execution_flag(true) if options[:force]
    yield
  ensure
    NewRelic::Agent.instance.pop_trace_execution_flag if options[:force]
    duration = (Time.now - t0).to_f              # for some reason this is 3 usec faster than Time - Time
    stat_engine.record_metrics(metric_names, 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



57
58
59
60
61
62
63
64
# File 'lib/new_relic/agent/method_tracer.rb', line 57

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.



88
89
90
91
92
93
# File 'lib/new_relic/agent/method_tracer.rb', line 88

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