module NewRelic::Agent::Transaction::TraceBuilder
Public Instance Methods
Source
# File lib/new_relic/agent/transaction/trace_builder.rb, line 15 def build_trace(transaction) trace = Trace.new(transaction.start_time) trace.root_node.exit_timestamp = transaction.end_time - transaction.start_time copy_attributes(transaction, trace) first, *rest = transaction.segments relationship_map = rest.group_by { |s| s.parent } trace.root_node.children << process_segments(transaction, first, trace.root_node, relationship_map) trace end
Private Instance Methods
Source
# File lib/new_relic/agent/transaction/trace_builder.rb, line 46 def copy_attributes(transaction, trace) trace.transaction_name = transaction.best_name trace.guid = transaction.guid trace.attributes = transaction.attributes trace.threshold = transaction.threshold trace.finished = true end
Source
# File lib/new_relic/agent/transaction/trace_builder.rb, line 40 def create_trace_node(transaction, segment, parent) relative_start = segment.start_time - transaction.start_time relative_end = segment.end_time - transaction.start_time TraceNode.new(segment.name, relative_start, relative_end, segment.params, parent) end
Source
# File lib/new_relic/agent/transaction/trace_builder.rb, line 28 def process_segments(transaction, segment, parent, relationship_map) current = create_trace_node(transaction, segment, parent) if children = relationship_map[segment] current.children = children.map! do |child| process_segments(transaction, child, current, relationship_map) end end current end
recursively builds a transaction trace from the flat list of segments