Module: NewRelic::Agent::Transaction::Tracing
- Included in:
- NewRelic::Agent::Transaction
- Defined in:
- lib/new_relic/agent/transaction/tracing.rb
Instance Attribute Summary collapse
- #async ⇒ Object writeonly
- #current_segment_by_thread ⇒ Object readonly
- #total_time ⇒ Object
Instance Method Summary collapse
- #add_segment(segment, parent = nil) ⇒ Object
- #async? ⇒ Boolean
- #segment_complete(segment) ⇒ Object
- #segment_limit ⇒ Object
- #thread_starting_span ⇒ Object
Instance Attribute Details
#async=(value) ⇒ Object (writeonly)
15 16 17 |
# File 'lib/new_relic/agent/transaction/tracing.rb', line 15 def async=(value) @async = value end |
#current_segment_by_thread ⇒ Object (readonly)
9 10 11 |
# File 'lib/new_relic/agent/transaction/tracing.rb', line 9 def current_segment_by_thread @current_segment_by_thread end |
#total_time ⇒ Object
17 18 19 |
# File 'lib/new_relic/agent/transaction/tracing.rb', line 17 def total_time @total_time ||= 0.0 end |
Instance Method Details
#add_segment(segment, parent = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# 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? ⇒ Boolean
11 12 13 |
# File 'lib/new_relic/agent/transaction/tracing.rb', line 11 def async? @async ||= false end |
#segment_complete(segment) ⇒ Object
52 53 54 55 56 57 58 59 |
# 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 ⇒ Object
61 62 63 |
# File 'lib/new_relic/agent/transaction/tracing.rb', line 61 def segment_limit Agent.config[:'transaction_tracer.limit_segments'] end |
#thread_starting_span ⇒ Object
42 43 44 45 46 47 48 49 50 |
# 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 |