Module: OneApm::Transaction::InstanceHelpers
- Included in:
- OneApm::Transaction
- Defined in:
- lib/one_apm/transaction/instance_helpers.rb
Constant Summary collapse
- HEX_DIGITS =
(0..15).map{|i| i.to_s(16)}
- GUID_LENGTH =
16
Instance Method Summary collapse
- #add_custom_parameters(p) ⇒ Object
- #agent ⇒ Object
- #custom_parameters ⇒ Object
-
#generate_guid ⇒ Object
generate a random 16 length uuid.
- #had_error? ⇒ Boolean
- #notable_exceptions ⇒ Object
- #queue_time ⇒ Object
- #recording_web_transaction? ⇒ Boolean
-
#referer ⇒ Object
For the current web transaction, return the full referer, minus the host string, or nil.
- #similar_category?(category) ⇒ Boolean
- #sql_sampler ⇒ Object
- #transaction_sampler ⇒ Object
-
#uri ⇒ Object
For the current web transaction, return the path of the URI minus the host part and query string, or nil.
- #web_category?(category) ⇒ Boolean
Instance Method Details
#add_custom_parameters(p) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 45 def add_custom_parameters(p) if OneApm::Manager.config[:high_security] OneApm::Manager.logger.debug("Unable to add custom attributes #{p.keys.inspect} while in high security mode.") return end custom_parameters.merge!(p) end |
#agent ⇒ Object
7 8 9 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 7 def agent OneApm::Manager.agent end |
#custom_parameters ⇒ Object
64 65 66 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 64 def custom_parameters @custom_parameters ||= {} end |
#generate_guid ⇒ Object
generate a random 16 length uuid
72 73 74 75 76 77 78 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 72 def generate_guid guid = '' GUID_LENGTH.times do |a| guid << HEX_DIGITS[rand(16)] end guid end |
#had_error? ⇒ Boolean
35 36 37 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 35 def had_error? !notable_exceptions.empty? end |
#notable_exceptions ⇒ Object
39 40 41 42 43 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 39 def notable_exceptions @exceptions.keys.select do |exception| !agent.error_collector.error_is_ignored?(exception) end end |
#queue_time ⇒ Object
31 32 33 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 31 def queue_time @apdex_start ? @start_time - @apdex_start : 0 end |
#recording_web_transaction? ⇒ Boolean
19 20 21 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 19 def recording_web_transaction? web_category?(@category) end |
#referer ⇒ Object
For the current web transaction, return the full referer, minus the host string, or nil.
60 61 62 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 60 def referer @referer ||= self.class.referer_from_request(@request) end |
#similar_category?(category) ⇒ Boolean
27 28 29 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 27 def similar_category?(category) web_category?(@category) == web_category?(category) end |
#sql_sampler ⇒ Object
15 16 17 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 15 def sql_sampler agent.sql_sampler end |
#transaction_sampler ⇒ Object
11 12 13 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 11 def transaction_sampler agent.transaction_sampler end |
#uri ⇒ Object
For the current web transaction, return the path of the URI minus the host part and query string, or nil.
55 56 57 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 55 def uri @uri ||= self.class.uri_from_request(@request) unless @request.nil? end |
#web_category?(category) ⇒ Boolean
23 24 25 |
# File 'lib/one_apm/transaction/instance_helpers.rb', line 23 def web_category?(category) Transaction::OA_WEB_TRANSACTION_CATEGORIES.include?(category) end |