vendor/plugins/newrelic_rpm/lib/newrelic/agent/method_tracer.rb
#
# it might be cleaner to have a hash for options, however that's going to be slower
# than direct parameters
#
it might be cleaner to have a hash for options, however that's going to be slower
than direct parameters
it might be cleaner to have a hash for options however that ' s going to be slower than direct parameters
def trace_method_execution (metric_name, push_scope, produce_metric, deduct_call_time_from_parent)
    t0 = Time.now
    stats = nil
    expected_scope = nil
    begin
      stats_engine = NewRelic::Agent.agent.stats_engine
      expected_scope = stats_engine.push_scope(metric_name, t0, deduct_call_time_from_parent) if push_scope
      stats = stats_engine.get_stats metric_name, push_scope if produce_metric
    rescue => e
      method_tracer_log.error("Caught exception in trace_method_execution header. Metric name = #{metric_name}, exception = #{e}")
      method_tracer_log.error(e.backtrace.join("\n"))
    end
    begin
      result = yield
    ensure
      t1 = Time.now
      duration = t1 - t0
      begin
        if expected_scope
          scope = stats_engine.pop_scope expected_scope, duration
          exclusive = duration - scope.children_time
        else
          exclusive = duration
        end
        stats.trace_call duration, exclusive if stats
      rescue => e
        method_tracer_log.error("Caught exception in trace_method_execution footer. Metric name = #{metric_name}, exception = #{e}")
        method_tracer_log.error(e.backtrace.join("\n"))
      end
      result 
    end
  end
def trace_method_execution ( metric_name , push_scope , produce_metric , deduct_call_time_from_parent ) t0 = Time . now stats = nil expected_scope = nil begin stats_engine = NewRelic :: Agent . agent . stats_engine expected_scope = stats_engine . push_scope ( metric_name , t0 , deduct_call_time_from_parent ) if push_scope stats = stats_engine . get_stats metric_name , push_scope if produce_metric rescue => e method_tracer_log . error ( "Caught exception in trace_method_execution header. Metric name = #{metric_name}, exception = #{e}" ) method_tracer_log . error ( e . backtrace . join ( "\n" ) ) end begin result = yield ensure t1 = Time . now duration = t1 - t0 begin if expected_scope scope = stats_engine . pop_scope expected_scope , duration exclusive = duration - scope . children_time else exclusive = duration end stats . trace_call duration , exclusive if stats rescue => e method_tracer_log . error ( "Caught exception in trace_method_execution footer. Metric name = #{metric_name}, exception = #{e}" ) method_tracer_log . error ( e . backtrace . join ( "\n" ) ) end result end end
it might be cleaner to have a hash for options, however that's going to be slower
than direct parameters
it might be cleaner to have a hash for options however that ' s going to be slower than direct parameters
metric_name
<not_specific>
push_scope
<not_specific>
produce_metric
<not_specific>
deduct_call_time_from_parent
<not_specific>