module NewRelic::Agent::Transaction::Tracing
Constants
- OTHER_TRANSACTION_TOTAL_TIME
- WEB_TRANSACTION_TOTAL_TIME
Attributes
async[W]
current_segment_by_thread[R]
total_time[W]
Public Instance Methods
add_segment(segment, parent = nil)
click to toggle source
# File lib/new_relic/agent/transaction/tracing.rb, line 23 def add_segment(segment, parent = nil) segment.transaction = self segment.parent = parent || thread_starting_span || current_segment set_current_segment(segment) if @segments.length < segment_limit @segments << segment else segment.record_on_finish = true ::NewRelic::Agent.logger.debug("Segment limit of #{segment_limit} reached, ceasing collection.") if finished? ::NewRelic::Agent.logger.debug("Transaction #{best_name} has finished but segments still being created, resetting state.") NewRelic::Agent::Tracer.state.reset NewRelic::Agent.record_metric('Supportability/Transaction/SegmentLimitReachedAfterFinished/ResetState', 1) end end segment.transaction_assigned end
async?()
click to toggle source
# File lib/new_relic/agent/transaction/tracing.rb, line 11 def async? @async ||= false end
segment_complete(segment)
click to toggle source
# File lib/new_relic/agent/transaction/tracing.rb, line 52 def segment_complete(segment) # if parent was in another thread, remove the current_segment entry for this thread if segment.parent && segment.parent.starting_segment_key != NewRelic::Agent::Tracer.current_segment_key remove_current_segment_by_thread_id(NewRelic::Agent::Tracer.current_segment_key) else set_current_segment(segment.parent) end end
segment_limit()
click to toggle source
# File lib/new_relic/agent/transaction/tracing.rb, line 61 def segment_limit Agent.config[:'transaction_tracer.limit_segments'] end
thread_starting_span()
click to toggle source
# File lib/new_relic/agent/transaction/tracing.rb, line 42 def thread_starting_span # if the previous current segment was in another thread, use the thread local parent if ThreadLocalStorage[:newrelic_thread_span_parent] && current_segment && current_segment.starting_segment_key != NewRelic::Agent::Tracer.current_segment_key ThreadLocalStorage[:newrelic_thread_span_parent] end end
total_time()
click to toggle source
# File lib/new_relic/agent/transaction/tracing.rb, line 17 def total_time @total_time ||= 0.0 end
Private Instance Methods
finalize_segments()
click to toggle source
# File lib/new_relic/agent/transaction/tracing.rb, line 67 def finalize_segments segments.each { |s| s.finalize } end
record_total_time_metrics()
click to toggle source
# File lib/new_relic/agent/transaction/tracing.rb, line 74 def record_total_time_metrics total_time_metric = if recording_web_transaction? WEB_TRANSACTION_TOTAL_TIME else OTHER_TRANSACTION_TOTAL_TIME end @metrics.record_unscoped(total_time_metric, total_time) @metrics.record_unscoped("#{total_time_metric}/#{@frozen_name}", total_time) end