Sha256: 23635d8c114733ae56d0d2196694087f5f132aa45609308898e7e9acf6156223

Contents?: true

Size: 1.33 KB

Versions: 15

Compression:

Stored size: 1.33 KB

Contents

# encoding: utf-8

require 'one_apm/transaction/sample_buffer/transaction_sample_buffer'

module OneApm
  class Transaction
    class DeveloperModeSampleBuffer < TransactionSampleBuffer

      CAPACITY = 100

      def capacity
        max_capacity
      end

      # Dev mode is allowed more than the typical upper limit.
      # Sidestep normal cap by overriding max_capacity.
      def max_capacity
        CAPACITY
      end

      def harvest_samples
        NO_SAMPLES
      end

      def enabled?
        Manager.config[:developer_mode]
      end

      # Truncate to the last capacity samples we've received
      def truncate_samples
        @samples = @samples.last(capacity)
      end

      # We don't hold onto previously trapped transactions on harvest
      # We've already got all the traces we want, thank you!
      def store_previous(*)
      end

      # Captures the stack trace for a segment
      # This is expensive and not for production mode
      def visit_segment(segment)
        return unless enabled? && segment

        trace = strip_oneapm_frames(caller)
        trace = trace.first(40) if trace.length > 40
        segment[:backtrace] = trace
      end

      def strip_oneapm_frames(trace)
        while trace.first =~/\/lib\/one_apm\/agent\//
          trace.shift
        end
        trace
      end

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
oneapm_rpm-1.2.7 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.7.rc1 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.6 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.6.rc1 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.5 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.5.rc1 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.4 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.4.rc1 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.3 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.3.rc2 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.2 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.2.rc lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.1 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.1.rc lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.2.0 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb