module OneApm::Transaction::InstanceHelpers

Constants

GUID_LENGTH
HEX_DIGITS

Public Instance Methods

add_custom_parameters(p) click to toggle source
# 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() click to toggle source
# File lib/one_apm/transaction/instance_helpers.rb, line 7
def agent
  OneApm::Manager.agent
end
custom_parameters() click to toggle source
# File lib/one_apm/transaction/instance_helpers.rb, line 64
def custom_parameters
  @custom_parameters ||= {}
end
generate_guid() click to toggle source

generate a random 16 length uuid

# 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?() click to toggle source
# File lib/one_apm/transaction/instance_helpers.rb, line 35
def had_error?
  !notable_exceptions.empty?
end
notable_exceptions() click to toggle source
# 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() click to toggle source
# File lib/one_apm/transaction/instance_helpers.rb, line 31
def queue_time
  @apdex_start ? @start_time - @apdex_start : 0
end
recording_web_transaction?() click to toggle source
# File lib/one_apm/transaction/instance_helpers.rb, line 19
def recording_web_transaction?
  web_category?(@category)
end
referer() click to toggle source

For the current web transaction, return the full referer, minus the host string, or nil.

# File lib/one_apm/transaction/instance_helpers.rb, line 60
def referer
  @referer ||= self.class.referer_from_request(@request)
end
similar_category?(category) click to toggle source
# File lib/one_apm/transaction/instance_helpers.rb, line 27
def similar_category?(category)
  web_category?(@category) == web_category?(category)
end
sql_sampler() click to toggle source
# File lib/one_apm/transaction/instance_helpers.rb, line 15
def sql_sampler
  agent.sql_sampler
end
transaction_sampler() click to toggle source
# File lib/one_apm/transaction/instance_helpers.rb, line 11
def transaction_sampler
  agent.transaction_sampler
end
uri() click to toggle source

For the current web transaction, return the path of the URI minus the host part and query string, or nil.

# 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) click to toggle source
# File lib/one_apm/transaction/instance_helpers.rb, line 23
def web_category?(category)
  Transaction::OA_WEB_TRANSACTION_CATEGORIES.include?(category)
end