module NewRelic::Agent::Transaction::Tracing
Constants
- OTHER_TRANSACTION_TOTAL_TIME
- WEB_TRANSACTION_TOTAL_TIME
Attributes
Public Instance Methods
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 @segment_lock.synchronize { @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
Source
# File lib/new_relic/agent/transaction/tracing.rb, line 11 def async? @async ||= false end
Source
# File lib/new_relic/agent/transaction/tracing.rb, line 51 def segment_complete(segment) # if parent was in another thread, remove the current_segment entry for this thread if 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
Source
# File lib/new_relic/agent/transaction/tracing.rb, line 60 def segment_limit Agent.config[:'transaction_tracer.limit_segments'] end
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&.starting_segment_key != NewRelic::Agent::Tracer.current_segment_key ThreadLocalStorage[:newrelic_thread_span_parent] end end
Source
# File lib/new_relic/agent/transaction/tracing.rb, line 17 def total_time @total_time ||= 0.0 end
Private Instance Methods
Source
# File lib/new_relic/agent/transaction/tracing.rb, line 66 def finalize_segments @segment_lock.synchronize { segments.each { |s| s&.finalize } } end
Source
# File lib/new_relic/agent/transaction/tracing.rb, line 73 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