class TingYun::Agent::Transaction::TraceNode
Constants
- UNKNOWN_NODE_NAME
Attributes
backtrace[RW]
called_nodes[R]
count[RW]
datas[RW]
entry_timestamp[R]
exception[RW]
exit_timestamp[RW]
klass[RW]
method[RW]
metric_name[RW]
name[RW]
params_data[RW]
parentTracerId[RW]
parent_node[R]
tracerId[RW]
type[RW]
uri[RW]
Public Class Methods
new(timestamp, metric_name,tracerId,option={})
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 22 def initialize(timestamp, metric_name,tracerId,option={}) @type = option[:type] || 'Java' @entry_timestamp = timestamp @metric_name = metric_name @called_nodes = nil @count = 1 if metric_name == "ROOT" @parentTracerId = -1 @tracerId = 0 else @tracerId = tracerId end @exception = [] @params_data = {} @backtrace = [] end
Public Instance Methods
[](key)
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 109 def [](key) params[key] end
[]=(key, value)
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 103 def []=(key, value) # only create a parameters field if a parameter is set; this will save # bandwidth etc as most nodes have no parameters params[key] = value end
add_called_node(s)
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 39 def add_called_node(s) @called_nodes ||= [] @called_nodes << s s.parent_node = self end
add_error(error)
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 145 def add_error(error) if error.respond_to?(:tingyun_external) exception << {"msg" => error.message, "name" => "External #{error.tingyun_code}", "stack"=> error.backtrace, "error"=> false } else if ::TingYun::Agent.config[:'nbs.exception.stack_enabled'] exception << {"msg" => error.message, "name" => error.class.name , "stack"=> error.backtrace.reject! { |t| t.include?('tingyun_rpm') }, "error"=> false } else exception << {"msg" => error.message, "name" => error.class.name, "stack"=> error.backtrace, "error"=> false } end end end
custom_params()
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 95 def custom_params {} end
duration()
click to toggle source
return the total duration of this node
# File lib/ting_yun/agent/transaction/trace_node.rb, line 51 def duration TingYun::Helper.time_to_millis(@exit_timestamp - @entry_timestamp) end
each_call(&blk)
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 125 def each_call(&blk) blk.call self if @called_nodes @called_nodes.each do |node| node.each_call(&blk) end end end
end_trace(timestamp)
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 45 def end_trace(timestamp) @parentTracerId = @parent_node.tracerId unless @parent_node.nil? @exit_timestamp = timestamp end
explain_sql()
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 135 def explain_sql return params[:explainPlan] if params.key?(:explainPlan) statement = params[:sql] return nil unless statement.respond_to?(:config) && statement.respond_to?(:explainer) TingYun::Agent::Database.explain_sql(statement) end
merge(hash)
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 121 def merge(hash) params.merge! hash end
params()
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 113 def params @params ||= {} end
params=(p)
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 117 def params=(p) @params = p end
pre_metric_name(metric_name)
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 56 def pre_metric_name(metric_name) @name ||= if metric_name.start_with?('Database ') "#{metric_name.split('/')[0]}/#{metric_name.split('/')[-1]}" else metric_name end end
request_params()
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 99 def request_params {} end
to_array()
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 64 def to_array [TingYun::Helper.time_to_millis(entry_timestamp), TingYun::Helper.time_to_millis(exit_timestamp), TingYun::Support::Coerce.string(metric_name), TingYun::Support::Coerce.string(uri)||'', TingYun::Support::Coerce.int(count), TingYun::Support::Coerce.string(klass)||TingYun::Support::Coerce.string(pre_metric_name(metric_name)), TingYun::Support::Coerce.string(method)||'', params] + [(@called_nodes ? @called_nodes.map{|s| s.to_array} : [])] end
to_hash()
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 76 def to_hash hash = { "parentTracerId" => @parentTracerId, "start" => TingYun::Helper.time_to_millis(entry_timestamp), "end" => TingYun::Helper.time_to_millis(exit_timestamp), "type"=> params[:type] || @type } hash["tracerId"]= @tracerId if @tracerId!=0 method = params[:method] || TingYun::Support::Coerce.string(method) hash["method"] = method unless method.nil? hash["metric"] = TingYun::Support::Coerce.string(metric_name) unless (metric_name.nil? or metric_name=="ROOT") clazz = params[:klass] || TingYun::Support::Coerce.string(klass) hash["clazz"] = clazz unless clazz.nil? hash["params"] = params_data unless params_data.empty? hash["backtrace"] = backtrace unless backtrace.empty? hash["exception"] = exception unless exception.empty? [hash].concat([(@called_nodes ? @called_nodes.map{|s| s.to_hash} : nil)].compact) end
Protected Instance Methods
parent_node=(s)
click to toggle source
# File lib/ting_yun/agent/transaction/trace_node.rb, line 170 def parent_node=(s) @parent_node = s end