Sha256: 9a8a798e5bdfdb1837a1561e86d793d12e3e2406a95dfc007e98c51e099fea19

Contents?: true

Size: 1.46 KB

Versions: 39

Compression:

Stored size: 1.46 KB

Contents

# encoding: utf-8

require 'one_apm/transaction/sample_buffer/transaction_sample_buffer'

module OneApm
  class Transaction
    class XraySampleBuffer < TransactionSampleBuffer

      attr_writer :xray_session_collection

      def initialize
        super

        # Memoize the config setting since this happens per request
        @enabled = OneApm::Manager.config[:'xray_session.allow_traces']
        OneApm::Manager.config.register_callback(:'xray_session.allow_traces') do |new_value|
          @enabled = new_value
        end

        @capacity = OneApm::Manager.config[:'xray_session.max_samples']
        OneApm::Manager.config.register_callback(:'xray_session.max_samples') do |new_value|
          @capacity = new_value
        end
      end

      def xray_session_collection
        @xray_session_collection ||= OneApm::Manager.agent.agent_command_router.xray_session_collection
      end

      def capacity
        @capacity
      end

      def truncate_samples
        # First in wins, so stop on allow_sample? instead of truncating
      end

      def allow_sample?(sample)
        !full? && !lookup_session_id(sample).nil?
      end

      def enabled?
        @enabled
      end


      private

      def add_sample(sample)
        super(sample)
        sample.xray_session_id = lookup_session_id(sample)
      end

      def lookup_session_id(sample)
        xray_session_collection.session_id_for_transaction_name(sample.transaction_name)
      end

    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
oneapm_rpm-1.4.2 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.4.1 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.4.0 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.7 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.7.rc1 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.6 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.6.rc1 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.5 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.5.rc1 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.4 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.4.rc1 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.3 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.3.rc1 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.2 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.2.rc1 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.1 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.1.rc1 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.0 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.3.0.rc1 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb
oneapm_rpm-1.2.9 lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb