class Mmtrix::Agent::TransactionSampleBuilder
a builder is created with every sampled transaction, to dynamically generate the sampled data. It is a thread-local object, and is not accessed by any other thread so no need for synchronization.
@api private
Constants
- TT_THRESHOLD_KEY
Attributes
current_node[R]
sample[R]
Public Class Methods
new(time=Time.now)
click to toggle source
# File lib/mmtrix/agent/transaction_sample_builder.rb, line 49 def initialize(time=Time.now) @sample = Mmtrix::Agent::Transaction::Trace.new(time.to_f) @sample_start = time.to_f @current_node = @sample.root_node end
Public Instance Methods
finish_trace(time=Time.now.to_f)
click to toggle source
# File lib/mmtrix/agent/transaction_sample_builder.rb, line 102 def finish_trace(time=Time.now.to_f) # Should never get called twice, but in a rare case that we can't # reproduce in house it does. log forensics and return gracefully if @sample.finished ::Mmtrix::Agent.logger.error "Unexpected double-finish_trace of Transaction Trace Object: \n#{@sample.to_s}" return end @sample.root_node.end_trace(time.to_f - @sample_start) @sample.threshold = transaction_trace_threshold @sample.finished = true @current_node = nil end
ignore_transaction()
click to toggle source
# File lib/mmtrix/agent/transaction_sample_builder.rb, line 63 def ignore_transaction @ignore = true end
ignored?()
click to toggle source
# File lib/mmtrix/agent/transaction_sample_builder.rb, line 59 def ignored? @ignore end
node_limit()
click to toggle source
# File lib/mmtrix/agent/transaction_sample_builder.rb, line 67 def node_limit Agent.config[:'transaction_tracer.limit_segments'] end
sample_id()
click to toggle source
# File lib/mmtrix/agent/transaction_sample_builder.rb, line 55 def sample_id @sample.sample_id end
scope_depth()
click to toggle source
# File lib/mmtrix/agent/transaction_sample_builder.rb, line 128 def scope_depth depth = -1 # have to account for the root current = @current_node while(current) depth += 1 current = current.parent_node end depth end
trace_entry(time)
click to toggle source
# File lib/mmtrix/agent/transaction_sample_builder.rb, line 71 def trace_entry(time) if @sample.count_nodes < node_limit node = @sample.create_node(time.to_f - @sample_start) @current_node.add_called_node(node) @current_node = node if @sample.count_nodes == node_limit() ::Mmtrix::Agent.logger.debug("Node limit of #{node_limit} reached, ceasing collection.") end else if @current_node.is_a?(PlaceholderNode) @current_node.depth += 1 else @current_node = PlaceholderNode.new(@current_node) end end @current_node end
trace_exit(metric_name, time)
click to toggle source
# File lib/mmtrix/agent/transaction_sample_builder.rb, line 89 def trace_exit(metric_name, time) if @current_node.is_a?(PlaceholderNode) @current_node.depth -= 1 if @current_node.depth == 0 @current_node = @current_node.parent_node end else @current_node.metric_name = metric_name @current_node.end_trace(time.to_f - @sample_start) @current_node = @current_node.parent_node end end
transaction_trace_threshold()
click to toggle source
# File lib/mmtrix/agent/transaction_sample_builder.rb, line 118 def transaction_trace_threshold #THREAD_LOCAL_ACCESS state = TransactionState.tl_get source_class = Agent.config.source(TT_THRESHOLD_KEY).class if source_class == Configuration::DefaultSource && state.current_transaction state.current_transaction.apdex_t * 4 else Agent.config[TT_THRESHOLD_KEY] end end