Class: NewRelic::Agent::Threading::BacktraceNode
- Inherits:
-
BacktraceBase
- Object
- BacktraceBase
- NewRelic::Agent::Threading::BacktraceNode
- Includes:
- Coerce
- Defined in:
- lib/new_relic/agent/threading/backtrace_node.rb
Instance Attribute Summary collapse
-
#as_array ⇒ Object
readonly
Returns the value of attribute as_array.
-
#depth ⇒ Object
Returns the value of attribute depth.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line_no ⇒ Object
readonly
Returns the value of attribute line_no.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#raw_line ⇒ Object
readonly
Returns the value of attribute raw_line.
-
#runnable_count ⇒ Object
Returns the value of attribute runnable_count.
Attributes inherited from BacktraceBase
Instance Method Summary collapse
- #==(other) ⇒ Object
- #complete_array_conversion ⇒ Object
- #dump_string(indent = 0) ⇒ Object
-
#initialize(line) ⇒ BacktraceNode
constructor
A new instance of BacktraceNode.
- #mark_for_array_conversion ⇒ Object
-
#parse_backtrace_frame(frame) ⇒ Object
Returns [filename, method, line number].
Methods included from Coerce
boolean_int!, float, float!, int, int!, int_or_nil, log_failure, scalar, string, value_or_nil
Methods inherited from BacktraceBase
#add_child, #add_child_unless_present, #find_child
Constructor Details
#initialize(line) ⇒ BacktraceNode
Returns a new instance of BacktraceNode.
84 85 86 87 88 89 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 84 def initialize(line) super() @raw_line = line @children = [] @runnable_count = 0 end |
Instance Attribute Details
#as_array ⇒ Object (readonly)
Returns the value of attribute as_array.
81 82 83 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 81 def as_array @as_array end |
#depth ⇒ Object
Returns the value of attribute depth.
82 83 84 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 82 def depth @depth end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
81 82 83 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 81 def file @file end |
#line_no ⇒ Object (readonly)
Returns the value of attribute line_no.
81 82 83 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 81 def line_no @line_no end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
81 82 83 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 81 def method @method end |
#raw_line ⇒ Object (readonly)
Returns the value of attribute raw_line.
81 82 83 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 81 def raw_line @raw_line end |
#runnable_count ⇒ Object
Returns the value of attribute runnable_count.
82 83 84 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 82 def runnable_count @runnable_count end |
Instance Method Details
#==(other) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 91 def ==(other) ( @raw_line == other.raw_line && @depth == other.depth && @runnable_count == other.runnable_count ) end |
#complete_array_conversion ⇒ Object
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 105 def complete_array_conversion child_arrays = @children.map { |c| c.as_array }.compact file, method, line = parse_backtrace_frame(@raw_line) @as_array << [string(file), string(method), line ? int(line) : UNKNOWN_LINE_NUMBER] @as_array << int(@runnable_count) @as_array << 0 @as_array << child_arrays end |
#dump_string(indent = 0) ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 116 def dump_string(indent = 0) @file, @method, @line_no = parse_backtrace_frame(@raw_line) indentation = ' ' * indent result = +"#{indentation}#<BacktraceNode:#{object_id} ) + \ [#{@runnable_count}] #{@file}:#{@line_no} in #{@method}>" child_results = @children.map { |c| c.dump_string(indent + 2) }.join("\n") result << "\n" unless child_results.empty? result << child_results end |
#mark_for_array_conversion ⇒ Object
99 100 101 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 99 def mark_for_array_conversion @as_array = [] end |
#parse_backtrace_frame(frame) ⇒ Object
Returns [filename, method, line number]
127 128 129 130 |
# File 'lib/new_relic/agent/threading/backtrace_node.rb', line 127 def parse_backtrace_frame(frame) frame =~ /([^:]*)(\:(\d+))?\:in `(.*)'/ [$1, $4, $3] # sic end |