module OneApm::Transaction::ThreadLocalAccess
Public Instance Methods
abort_transaction!()
click to toggle source
Indicate that you don't want to keep the currently saved transaction information
# File lib/one_apm/transaction/thread_local_access.rb, line 30 def abort_transaction! state = OneApm::TransactionState.tl_get txn = state.current_transaction txn.abort_transaction!(state) if txn end
extract_request_options(options)
click to toggle source
# File lib/one_apm/transaction/thread_local_access.rb, line 57 def extract_request_options(options) req = options.delete(:request) if req options[:uri] = uri_from_request(req) options[:referer] = referer_from_request(req) end options end
notice_error(e, options={})
click to toggle source
If we have an active transaction, notice the error and increment the error metric. Options:
-
:request
=> Request object to get the uri and referer -
:uri
=> The request path, minus any request params or query string. -
:referer
=> The URI of the referer -
:metric
=> The metric name associated with the transaction -
:request_params
=> Request parameters, already filtered if necessary -
:custom_params
=> Custom parameters
Anything left over is treated as custom params
# File lib/one_apm/transaction/thread_local_access.rb, line 46 def notice_error(e, options={}) options = extract_request_options(options) state = OneApm::TransactionState.tl_get txn = state.current_transaction if txn txn.notice_error(e, options) else OneApm::Manager.agent.error_collector.notice_error(e, options) end end
recording_web_transaction?()
click to toggle source
# File lib/one_apm/transaction/thread_local_access.rb, line 66 def recording_web_transaction? txn = tl_current txn && txn.recording_web_transaction? end
set_default_transaction_name(name, category = nil, segment_name = nil)
click to toggle source
# File lib/one_apm/transaction/thread_local_access.rb, line 11 def set_default_transaction_name(name, category = nil, segment_name = nil) txn = tl_current name = txn.make_transaction_name(name, category) txn.name_last_frame(segment_name || name) txn.set_default_transaction_name(name, category) end
set_overriding_transaction_name(name, category = nil)
click to toggle source
# File lib/one_apm/transaction/thread_local_access.rb, line 18 def set_overriding_transaction_name(name, category = nil) txn = tl_current return unless txn name = txn.make_transaction_name(name, category) txn.name_last_frame(name) txn.set_overriding_transaction_name(name, category) end
tl_current()
click to toggle source
# File lib/one_apm/transaction/thread_local_access.rb, line 7 def tl_current TransactionState.tl_get.current_transaction end