Class: TingYun::Agent::Transaction
- Inherits:
-
Object
- Object
- TingYun::Agent::Transaction
- Extended by:
- ClassMethod
- Includes:
- InstanceMethod
- Defined in:
- lib/ting_yun/agent/transaction.rb,
lib/ting_yun/agent/transaction/apdex.rb,
lib/ting_yun/agent/transaction/trace.rb,
lib/ting_yun/agent/transaction/attributes.rb,
lib/ting_yun/agent/transaction/exceptions.rb,
lib/ting_yun/agent/transaction/trace_node.rb,
lib/ting_yun/agent/transaction/class_method.rb,
lib/ting_yun/agent/transaction/instance_method.rb,
lib/ting_yun/agent/transaction/request_attributes.rb
Overview
web transaction
Defined Under Namespace
Modules: ClassMethod, InstanceMethod Classes: Apdex, Attributes, Exceptions, RequestAttributes, Trace, TraceNode
Constant Summary collapse
- SUBTRANSACTION_PREFIX =
'Nested/'.freeze
- CONTROLLER_PREFIX =
'WebAction/'.freeze
- BACKGROUND_PREFIX =
'BackgroundAction/'.freeze
- RAKE_TRANSACTION_PREFIX =
'BackgroundAction/Rake'.freeze
- TASK_PREFIX =
'OtherTransaction/Background/'.freeze
- RACK_PREFIX =
'Rack/'.freeze
- SINATRA_PREFIX =
'WebAction/Sinatra/'.freeze
- MIDDLEWARE_PREFIX =
'Middleware/'.freeze
- GRAPE_PREFIX =
'WebAction/Grape/'.freeze
- RAKE_PREFIX =
'WebAction/Rake'.freeze
- CABLE_PREFIX =
'WebAction/ActionCable'.freeze
- EMPTY_SUMMARY_METRICS =
[].freeze
- MIDDLEWARE_SUMMARY_METRICS =
['Middleware/all'.freeze].freeze
- TRACE_OPTIONS_SCOPED =
{:metric => true, :scoped_metric => true}.freeze
- TRACE_OPTIONS_UNSCOPED =
{:metric => true, :scoped_metric => false}.freeze
- NESTED_TRACE_STOP_OPTIONS =
{:metric => true}.freeze
Constants included from InstanceMethod
InstanceMethod::GUID_LENGTH, InstanceMethod::HEX_DIGITS, InstanceMethod::WEB_TRANSACTION_CATEGORIES
Instance Attribute Summary collapse
-
#apdex ⇒ Object
readonly
Returns the value of attribute apdex.
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#base_quantile_hash ⇒ Object
readonly
Returns the value of attribute base_quantile_hash.
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#default_name ⇒ Object
readonly
Returns the value of attribute default_name.
-
#exceptions ⇒ Object
readonly
Returns the value of attribute exceptions.
-
#frame_stack ⇒ Object
readonly
Returns the value of attribute frame_stack.
-
#guid ⇒ Object
readonly
Returns the value of attribute guid.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
-
#request_attributes ⇒ Object
readonly
Returns the value of attribute request_attributes.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
- #commit(state, end_time, outermost_node_name) ⇒ Object
- #frozen_name=(name) ⇒ Object
-
#initialize(category, client_transaction_id, options) ⇒ Transaction
constructor
A new instance of Transaction.
- #request_path ⇒ Object
- #request_port ⇒ Object
- #start(state) ⇒ Object
- #stop(state, end_time, outermost_frame, summary_metrics = []) ⇒ Object
Methods included from ClassMethod
nested_transaction_name, notice_error, recording_web_transaction?, set_default_transaction_name, set_frozen_transaction_name!, start_new_transaction, tl_current, wrap
Methods included from InstanceMethod
#assign_agent_attributes, #best_name, #create_nested_frame, #freeze_name_and_execute, #ignore!, #ignore?, #influences_transaction_name?, #instrumentation_state, #make_transaction_name, #name_last_frame, #needs_middleware_summary_metrics?, #record_summary_metrics, #set_default_transaction_name, #similar_category?, #web_category?, #with_database_metric_name
Constructor Details
#initialize(category, client_transaction_id, options) ⇒ Transaction
Returns a new instance of Transaction.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/ting_yun/agent/transaction.rb', line 68 def initialize(category, client_transaction_id, ) @start_time = Time.now.to_f @exceptions = TingYun::Agent::Transaction::Exceptions.new @metrics = TingYun::Agent::TransactionMetrics.new @attributes = TingYun::Agent::Transaction::Attributes.new @apdex = TingYun::Agent::Transaction::Apdex.new([:apdex_start_time], @start_time) @has_children = false @category = category @is_mq = [:mq] || false @guid = client_transaction_id || generate_guid @frame_stack = [] @frozen_name = nil @base_quantile_hash = {} @default_name = TingYun::Helper.correctly_encoded([:transaction_name]) if request = [:request] @request_attributes = TingYun::Agent::Transaction::RequestAttributes.new request else @request_attributes = nil end end |
Instance Attribute Details
#apdex ⇒ Object (readonly)
Returns the value of attribute apdex.
54 55 56 |
# File 'lib/ting_yun/agent/transaction.rb', line 54 def apdex @apdex end |
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
54 55 56 |
# File 'lib/ting_yun/agent/transaction.rb', line 54 def attributes @attributes end |
#base_quantile_hash ⇒ Object (readonly)
Returns the value of attribute base_quantile_hash.
54 55 56 |
# File 'lib/ting_yun/agent/transaction.rb', line 54 def base_quantile_hash @base_quantile_hash end |
#category ⇒ Object (readonly)
Returns the value of attribute category.
54 55 56 |
# File 'lib/ting_yun/agent/transaction.rb', line 54 def category @category end |
#default_name ⇒ Object (readonly)
Returns the value of attribute default_name.
54 55 56 |
# File 'lib/ting_yun/agent/transaction.rb', line 54 def default_name @default_name end |
#exceptions ⇒ Object (readonly)
Returns the value of attribute exceptions.
54 55 56 |
# File 'lib/ting_yun/agent/transaction.rb', line 54 def exceptions @exceptions end |
#frame_stack ⇒ Object (readonly)
Returns the value of attribute frame_stack.
54 55 56 |
# File 'lib/ting_yun/agent/transaction.rb', line 54 def frame_stack @frame_stack end |
#guid ⇒ Object (readonly)
Returns the value of attribute guid.
54 55 56 |
# File 'lib/ting_yun/agent/transaction.rb', line 54 def guid @guid end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
54 55 56 |
# File 'lib/ting_yun/agent/transaction.rb', line 54 def metrics @metrics end |
#request_attributes ⇒ Object (readonly)
Returns the value of attribute request_attributes.
54 55 56 |
# File 'lib/ting_yun/agent/transaction.rb', line 54 def request_attributes @request_attributes end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
54 55 56 |
# File 'lib/ting_yun/agent/transaction.rb', line 54 def start_time @start_time end |
Instance Method Details
#commit(state, end_time, outermost_node_name) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/ting_yun/agent/transaction.rb', line 152 def commit(state, end_time, outermost_node_name) assign_agent_attributes(state) TingYun::Agent.instance.transaction_sampler.on_finishing_transaction(state, self, end_time,@exceptions) TingYun::Agent.instance.sql_sampler.on_finishing_transaction(state, @frozen_name) record_summary_metrics(state, outermost_node_name, end_time) unless @exceptions.had_error? @apdex.record_apdex(@frozen_name, end_time, @exceptions.had_error?) @exceptions.record_exceptions(@attributes) TingYun::Agent.instance.stats_engine.merge_transaction_metrics!(@metrics, best_name) TingYun::Agent.instance.stats_engine.record_base_quantile(@base_quantile_hash) unless @exceptions.had_error? end |
#frozen_name=(name) ⇒ Object
101 102 103 |
# File 'lib/ting_yun/agent/transaction.rb', line 101 def frozen_name=(name) @frozen_name = name end |
#request_path ⇒ Object
93 94 95 |
# File 'lib/ting_yun/agent/transaction.rb', line 93 def request_path @request_attributes && @request_attributes.request_path end |
#request_port ⇒ Object
97 98 99 |
# File 'lib/ting_yun/agent/transaction.rb', line 97 def request_port @request_attributes && @request_attributes.port end |
#start(state) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/ting_yun/agent/transaction.rb', line 105 def start(state) return if !state.execution_traced? ::TingYun::Agent.instance.events.notify(:start_transaction) # Dispatcher调用 ::TingYun::Agent::Collector::TransactionSampler.on_start_transaction(state, start_time) ::TingYun::Agent::Collector::SqlSampler.on_start_transaction(state, request_path) frame_stack.push TingYun::Agent::MethodTracerHelpers.trace_execution_scoped_header(state, Time.now.to_f) name_last_frame @default_name freeze_name_and_execute if @default_name.start_with?(RAKE_TRANSACTION_PREFIX) end |
#stop(state, end_time, outermost_frame, summary_metrics = []) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/ting_yun/agent/transaction.rb', line 120 def stop(state, end_time, outermost_frame, summary_metrics = []) freeze_name_and_execute if @has_children or @is_mq name = Transaction.nested_transaction_name(outermost_frame.name) = TRACE_OPTIONS_SCOPED else name = @frozen_name = TRACE_OPTIONS_UNSCOPED end # if name.start_with?(MIDDLEWARE_PREFIX) # summary_metrics_with_exclusive_time = MIDDLEWARE_SUMMARY_METRICS # else # summary_metrics_with_exclusive_time = EMPTY_SUMMARY_METRICS # end # summary_metrics_with_exclusive_time = summary_metrics unless summary_metrics.empty? TingYun::Agent::MethodTracerHelpers.( state, start_time, name, EMPTY_SUMMARY_METRICS, outermost_frame, , end_time) commit(state, end_time, name) end |