Module: NewRelic::Agent::Transaction::Tracing

Included in:
NewRelic::Agent::Transaction
Defined in:
lib/new_relic/agent/transaction/tracing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_threadObject (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_timeObject



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

Returns:

  • (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_limitObject



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_spanObject



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 ::Thread.current[:newrelic_thread_span_parent] &&
      current_segment &&
      current_segment.starting_segment_key != NewRelic::Agent::Tracer.current_segment_key

    ::Thread.current[:newrelic_thread_span_parent]
  end
end