Class: NewRelic::Agent::TransactionState
- Inherits:
-
Object
- Object
- NewRelic::Agent::TransactionState
- Defined in:
- lib/new_relic/agent/transaction_state.rb
Overview
This is THE location to store thread local information during a transaction Need a new piece of data? Add a method here, NOT a new thread local variable.
Instance Attribute Summary collapse
-
#busy_entries ⇒ Object
Busy calculator.
-
#client_cross_app_id ⇒ Object
Cross app tracing Because we need values from headers before the transaction actually starts.
-
#current_transaction_stack ⇒ Object
Returns and initializes the transaction stack if necessary.
-
#record_sql ⇒ Object
TT’s and SQL.
-
#record_tt ⇒ Object
TT’s and SQL.
-
#referring_transaction_info ⇒ Object
Cross app tracing Because we need values from headers before the transaction actually starts.
-
#request ⇒ Object
Request data.
-
#request_guid ⇒ Object
Request data.
-
#request_ignore_enduser ⇒ Object
Request data.
-
#request_token ⇒ Object
Request data.
-
#sql_sampler_transaction_data ⇒ Object
Sql Sampler Transaction Data.
-
#stats_scope_stack ⇒ Object
Scope stack tracking from NewRelic::StatsEngine::Transactions Should not be nil–this class manages its initialization and resetting.
-
#transaction ⇒ Object
Current transaction stack and sample building.
-
#transaction_sample_builder ⇒ Object
Current transaction stack and sample building.
-
#untraced ⇒ Object
Execution tracing on current thread.
Class Method Summary collapse
- .clear ⇒ Object
- .get ⇒ Object
- .in_background_transaction?(thread) ⇒ Boolean
- .in_request_transaction?(thread) ⇒ Boolean
-
.reset(request = nil) ⇒ Object
This starts the timer for the transaction.
Instance Method Summary collapse
- #clear_stats_scope_stack ⇒ Object
- #current_transaction ⇒ Object
- #has_current_transaction? ⇒ Boolean
- #in_background_transaction? ⇒ Boolean
- #in_request_transaction? ⇒ Boolean
-
#initialize ⇒ TransactionState
constructor
A new instance of TransactionState.
- #is_sql_recorded? ⇒ Boolean
- #is_traced? ⇒ Boolean
- #is_transaction_traced? ⇒ Boolean
- #pop_traced ⇒ Object
- #push_traced(should_trace) ⇒ Object
- #reset(request) ⇒ Object
- #timings ⇒ Object
- #transaction_name ⇒ Object
- #transaction_noticed_error_ids ⇒ Object
- #transaction_queue_time ⇒ Object
- #transaction_start_time ⇒ Object
Constructor Details
#initialize ⇒ TransactionState
Returns a new instance of TransactionState.
36 37 38 |
# File 'lib/new_relic/agent/transaction_state.rb', line 36 def initialize @stats_scope_stack = [] end |
Instance Attribute Details
#busy_entries ⇒ Object
Busy calculator
151 152 153 |
# File 'lib/new_relic/agent/transaction_state.rb', line 151 def busy_entries @busy_entries end |
#client_cross_app_id ⇒ Object
Cross app tracing Because we need values from headers before the transaction actually starts
61 62 63 |
# File 'lib/new_relic/agent/transaction_state.rb', line 61 def client_cross_app_id @client_cross_app_id end |
#current_transaction_stack ⇒ Object
Returns and initializes the transaction stack if necessary
We don’t default in the initializer so non-transaction threads retain a nil stack, and methods in this class use has_current_transction? instead of this accessor to see if we’re a transaction thread or not
75 76 77 |
# File 'lib/new_relic/agent/transaction_state.rb', line 75 def current_transaction_stack @current_transaction_stack ||= [] end |
#record_sql ⇒ Object
TT’s and SQL
140 141 142 |
# File 'lib/new_relic/agent/transaction_state.rb', line 140 def record_sql @record_sql end |
#record_tt ⇒ Object
TT’s and SQL
140 141 142 |
# File 'lib/new_relic/agent/transaction_state.rb', line 140 def record_tt @record_tt end |
#referring_transaction_info ⇒ Object
Cross app tracing Because we need values from headers before the transaction actually starts
61 62 63 |
# File 'lib/new_relic/agent/transaction_state.rb', line 61 def referring_transaction_info @referring_transaction_info end |
#request ⇒ Object
Request data
64 65 66 |
# File 'lib/new_relic/agent/transaction_state.rb', line 64 def request @request end |
#request_guid ⇒ Object
Request data
64 65 66 |
# File 'lib/new_relic/agent/transaction_state.rb', line 64 def request_guid @request_guid end |
#request_ignore_enduser ⇒ Object
Request data
64 65 66 |
# File 'lib/new_relic/agent/transaction_state.rb', line 64 def request_ignore_enduser @request_ignore_enduser end |
#request_token ⇒ Object
Request data
64 65 66 |
# File 'lib/new_relic/agent/transaction_state.rb', line 64 def request_token @request_token end |
#sql_sampler_transaction_data ⇒ Object
Sql Sampler Transaction Data
154 155 156 |
# File 'lib/new_relic/agent/transaction_state.rb', line 154 def sql_sampler_transaction_data @sql_sampler_transaction_data end |
#stats_scope_stack ⇒ Object
Scope stack tracking from NewRelic::StatsEngine::Transactions Should not be nil–this class manages its initialization and resetting
158 159 160 |
# File 'lib/new_relic/agent/transaction_state.rb', line 158 def stats_scope_stack @stats_scope_stack end |
#transaction ⇒ Object
Current transaction stack and sample building
67 68 69 |
# File 'lib/new_relic/agent/transaction_state.rb', line 67 def transaction @transaction end |
#transaction_sample_builder ⇒ Object
Current transaction stack and sample building
67 68 69 |
# File 'lib/new_relic/agent/transaction_state.rb', line 67 def transaction_sample_builder @transaction_sample_builder end |
#untraced ⇒ Object
Execution tracing on current thread
124 125 126 |
# File 'lib/new_relic/agent/transaction_state.rb', line 124 def untraced @untraced end |
Class Method Details
.clear ⇒ Object
27 28 29 |
# File 'lib/new_relic/agent/transaction_state.rb', line 27 def self.clear Thread.current[:newrelic_transaction_state] = nil end |
.get ⇒ Object
14 15 16 |
# File 'lib/new_relic/agent/transaction_state.rb', line 14 def self.get state_for(Thread.current) end |
.in_background_transaction?(thread) ⇒ Boolean
99 100 101 |
# File 'lib/new_relic/agent/transaction_state.rb', line 99 def self.in_background_transaction?(thread) state_for(thread).in_background_transaction? end |
.in_request_transaction?(thread) ⇒ Boolean
103 104 105 |
# File 'lib/new_relic/agent/transaction_state.rb', line 103 def self.in_request_transaction?(thread) state_for(thread).in_request_transaction? end |
.reset(request = nil) ⇒ Object
This starts the timer for the transaction.
32 33 34 |
# File 'lib/new_relic/agent/transaction_state.rb', line 32 def self.reset(request=nil) self.get.reset(request) end |
Instance Method Details
#clear_stats_scope_stack ⇒ Object
160 161 162 |
# File 'lib/new_relic/agent/transaction_state.rb', line 160 def clear_stats_scope_stack @stats_scope_stack = [] end |
#current_transaction ⇒ Object
115 116 117 |
# File 'lib/new_relic/agent/transaction_state.rb', line 115 def current_transaction current_transaction_stack.last if has_current_transaction? end |
#has_current_transaction? ⇒ Boolean
119 120 121 |
# File 'lib/new_relic/agent/transaction_state.rb', line 119 def has_current_transaction? !@current_transaction_stack.nil? end |
#in_background_transaction? ⇒ Boolean
107 108 109 |
# File 'lib/new_relic/agent/transaction_state.rb', line 107 def in_background_transaction? !current_transaction.nil? && current_transaction.request.nil? end |
#in_request_transaction? ⇒ Boolean
111 112 113 |
# File 'lib/new_relic/agent/transaction_state.rb', line 111 def in_request_transaction? !current_transaction.nil? && !current_transaction.request.nil? end |
#is_sql_recorded? ⇒ Boolean
146 147 148 |
# File 'lib/new_relic/agent/transaction_state.rb', line 146 def is_sql_recorded? @record_sql != false end |
#is_traced? ⇒ Boolean
135 136 137 |
# File 'lib/new_relic/agent/transaction_state.rb', line 135 def is_traced? @untraced.nil? || @untraced.last != false end |
#is_transaction_traced? ⇒ Boolean
142 143 144 |
# File 'lib/new_relic/agent/transaction_state.rb', line 142 def is_transaction_traced? @record_tt != false end |
#pop_traced ⇒ Object
131 132 133 |
# File 'lib/new_relic/agent/transaction_state.rb', line 131 def pop_traced @untraced.pop if @untraced end |
#push_traced(should_trace) ⇒ Object
126 127 128 129 |
# File 'lib/new_relic/agent/transaction_state.rb', line 126 def push_traced(should_trace) @untraced ||= [] @untraced << should_trace end |
#reset(request) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/new_relic/agent/transaction_state.rb', line 40 def reset(request) # We almost always want to use the transaction time, but in case it's # not available, we track the last reset. No accessor, as only the # TransactionState class should use it. @last_reset_time = Time.now @transaction = Transaction.current @timings = nil @request = request @request_token = BrowserToken.get_token(request) @request_guid = "" @request_ignore_enduser = false end |
#timings ⇒ Object
55 56 57 |
# File 'lib/new_relic/agent/transaction_state.rb', line 55 def timings @timings ||= TransactionTimings.new(transaction_queue_time, transaction_start_time, transaction_name) end |
#transaction_name ⇒ Object
91 92 93 |
# File 'lib/new_relic/agent/transaction_state.rb', line 91 def transaction_name transaction.nil? ? nil : transaction.name end |
#transaction_noticed_error_ids ⇒ Object
95 96 97 |
# File 'lib/new_relic/agent/transaction_state.rb', line 95 def transaction_noticed_error_ids transaction.nil? ? [] : transaction.noticed_error_ids end |
#transaction_queue_time ⇒ Object
87 88 89 |
# File 'lib/new_relic/agent/transaction_state.rb', line 87 def transaction_queue_time transaction.nil? ? 0.0 : transaction.queue_time end |
#transaction_start_time ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/new_relic/agent/transaction_state.rb', line 79 def transaction_start_time if transaction.nil? @last_reset_time else transaction.start_time end end |