Module: NewRelic::Agent::Instrumentation::MetricFrame::Pop

Included in:
NewRelic::Agent::Instrumentation::MetricFrame
Defined in:
lib/new_relic/agent/instrumentation/metric_frame/pop.rb

Instance Method Summary collapse

Instance Method Details

#clear_thread_metric_frame!Object



8
9
10
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 8

def clear_thread_metric_frame!
  Thread.current[:newrelic_metric_frame] = nil
end

#cpu_burnObject



49
50
51
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 49

def cpu_burn
  normal_cpu_burn || jruby_cpu_burn
end

#current_stack_metricObject



73
74
75
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 73

def current_stack_metric
  metric_name
end

#end_transaction!Object



53
54
55
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 53

def end_transaction!
  agent.stats_engine.end_transaction
end

#handle_empty_path_stack(metric) ⇒ Object



66
67
68
69
70
71
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 66

def handle_empty_path_stack(metric)
  raise 'path stack not empty' unless @path_stack.empty?
  notify_transaction_sampler(metric.is_web_transaction?) if traced?
  end_transaction!
  clear_thread_metric_frame!
end

#jruby_cpu_burnObject



35
36
37
38
39
40
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 35

def jruby_cpu_burn
  return unless @jruby_cpu_start
  burn = (jruby_cpu_time - @jruby_cpu_start)
  record_jruby_cpu_burn(burn)
  burn
end

#log_underflowObject



16
17
18
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 16

def log_underflow
  NewRelic::Agent.logger.error "Underflow in metric frames: #{caller.join("\n   ")}"
end

#normal_cpu_burnObject



30
31
32
33
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 30

def normal_cpu_burn
  return unless @process_cpu_start
  process_cpu - @process_cpu_start
end

#notice_scope_emptyObject



20
21
22
23
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 20

def notice_scope_empty
  transaction_sampler.notice_scope_empty
  sql_sampler.notice_scope_empty
end

#notify_transaction_sampler(web_transaction) ⇒ Object



57
58
59
60
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 57

def notify_transaction_sampler(web_transaction)
  record_transaction_cpu
  notice_scope_empty
end

#record_jruby_cpu_burn(burn) ⇒ Object

we need to do this here because the normal cpu sampler process doesn’t work on JRuby. See the cpu_sampler.rb file to understand where cpu is recorded for non-jruby processes



45
46
47
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 45

def record_jruby_cpu_burn(burn)
  NewRelic::Agent.get_stats_no_scope(NewRelic::Metrics::USER_TIME).record_data_point(burn)
end

#record_transaction_cpuObject



25
26
27
28
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 25

def record_transaction_cpu
  burn = cpu_burn
  transaction_sampler.notice_transaction_cpu_time(burn) if burn
end

#set_new_scope!(metric) ⇒ Object



12
13
14
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 12

def set_new_scope!(metric)
  agent.stats_engine.scope_name = metric
end

#traced?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/new_relic/agent/instrumentation/metric_frame/pop.rb', line 62

def traced?
  NewRelic::Agent.is_execution_traced?
end