class Mmtrix::Agent::Transaction::Trace
Attributes
attributes[RW]
finished[RW]
guid[RW]
node_count[RW]
profile[RW]
root_node[R]
start_time[R]
threshold[RW]
transaction_name[RW]
uri[RW]
xray_session_id[RW]
Public Class Methods
new(start_time)
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 18 def initialize(start_time) @start_time = start_time @node_count = 0 @root_node = Mmtrix::Agent::Transaction::TraceNode.new(0.0, "ROOT") end
Public Instance Methods
collect_explain_plans!()
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 74 def collect_explain_plans! return unless Mmtrix::Agent::Database.should_collect_explain_plans? threshold = Mmtrix::Agent.config[:'transaction_tracer.explain_threshold'] each_node do |node| if node[:sql] && node.duration > threshold node[:explain_plan] = node.explain_sql end end end
count_nodes()
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 28 def count_nodes self.node_count end
create_node(time_since_start, metric_name = nil)
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 50 def create_node(time_since_start, metric_name = nil) raise FinishedTraceError.new "Can't create additional node for finished trace." if self.finished self.node_count += 1 Mmtrix::Agent::Transaction::TraceNode.new(time_since_start, metric_name) end
duration()
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 32 def duration self.root_node.duration end
each_node(&block)
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 56 def each_node(&block) self.root_node.each_node(&block) end
each_node_with_nest_tracking(&block)
click to toggle source
Iterates recursively over each node in the entire transaction sample tree while keeping track of nested nodes
# File lib/mmtrix/agent/transaction/trace.rb, line 109 def each_node_with_nest_tracking(&block) @root_node.each_node_with_nest_tracking(&block) end
forced?()
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 36 def forced? return true if Mmtrix::Coerce.int_or_nil(xray_session_id) false end
prepare_sql_for_transmission!()
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 85 def prepare_sql_for_transmission! strategy = Mmtrix::Agent::Database.record_sql_method each_node do |node| next unless node[:sql] case strategy when :obfuscated node[:sql] = Mmtrix::Agent::Database.obfuscate_sql(node[:sql]) when :raw node[:sql] = node[:sql].to_s else node[:sql] = nil end end end
prepare_to_send!()
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 60 def prepare_to_send! return self if @prepared if Mmtrix::Agent::Database.should_record_sql? collect_explain_plans! prepare_sql_for_transmission! else strip_sql! end @prepared = true self end
sample_id()
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 24 def sample_id self.object_id end
strip_sql!()
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 101 def strip_sql! each_node do |node| node.params.delete(:sql) end end
synthetics_resource_id()
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 41 def synthetics_resource_id intrinsic_attributes = attributes.intrinsic_attributes_for(Mmtrix::Agent::AttributeFilter::DST_TRANSACTION_TRACER) intrinsic_attributes[:synthetics_resource_id] end
to_collector_array(encoder)
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 133 def to_collector_array(encoder) [ Mmtrix::Helper.time_to_millis(self.start_time), Mmtrix::Helper.time_to_millis(self.root_node.duration), Mmtrix::Coerce.string(self.transaction_name), Mmtrix::Coerce.string(self.uri), encoder.encode(trace_tree), Mmtrix::Coerce.string(self.guid), nil, forced?, Mmtrix::Coerce.int_or_nil(xray_session_id), Mmtrix::Coerce.string(self.synthetics_resource_id) ] end
to_s_compact()
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 46 def to_s_compact @root_node.to_s_compact end
trace_tree()
click to toggle source
# File lib/mmtrix/agent/transaction/trace.rb, line 113 def trace_tree destination = Mmtrix::Agent::AttributeFilter::DST_TRANSACTION_TRACER agent_attributes = self.attributes.agent_attributes_for(destination) custom_attributes = self.attributes.custom_attributes_for(destination) intrinsic_attributes = self.attributes.intrinsic_attributes_for(destination) [ Mmtrix::Coerce.float(self.start_time), {}, {}, self.root_node.to_array, { 'agentAttributes' => agent_attributes, 'userAttributes' => custom_attributes, 'intrinsics' => intrinsic_attributes } ] end