Sha256: 789f977c1a4eda6d1964c5218d96d64f05f961d107614e3c1d0809bcf72a45df

Contents?: true

Size: 1.88 KB

Versions: 34

Compression:

Stored size: 1.88 KB

Contents

# encoding: utf-8

module OneApm
  class Transaction
    module InstanceHelpers

      def agent
        OneApm::Manager.agent
      end

      def transaction_sampler
        agent.transaction_sampler
      end

      def sql_sampler
        agent.sql_sampler
      end

      def recording_web_transaction?
        web_category?(@category)
      end

      def web_category?(category)
        Transaction::WEB_TRANSACTION_CATEGORIES.include?(category)
      end

      def similar_category?(category)
        web_category?(@category) == web_category?(category)
      end

      def queue_time
        @apdex_start ? @start_time - @apdex_start : 0
      end

      def had_error?
        !notable_exceptions.empty?
      end

      def notable_exceptions
        @exceptions.keys.select do |exception|
          !agent.error_collector.error_is_ignored?(exception)
        end
      end

      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

      # For the current web transaction, return the path of the URI minus the host part and query string, or nil.
      def uri
        @uri ||= self.class.uri_from_request(@request) unless @request.nil?
      end

      # For the current web transaction, return the full referer, minus the host string, or nil.
      def referer
        @referer ||= self.class.referer_from_request(@request)
      end

      def custom_parameters
        @custom_parameters ||= {}
      end

      HEX_DIGITS = (0..15).map{|i| i.to_s(16)}
      GUID_LENGTH = 16

      # generate a random 64 bit uuid
      def generate_guid
        guid = ''
        GUID_LENGTH.times do |a|
          guid << HEX_DIGITS[rand(16)]
        end
        guid
      end

    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
oneapm_rpm-1.3.6 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.6.rc1 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.5 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.5.rc1 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.4 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.4.rc1 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.3 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.3.rc1 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.2 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.2.rc1 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.1 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.1.rc1 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.0 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.3.0.rc1 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.2.9 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.2.9.rc1 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.2.8 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.2.8.rc1 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.2.7 lib/one_apm/transaction/instance_helpers.rb
oneapm_rpm-1.2.7.rc1 lib/one_apm/transaction/instance_helpers.rb