Sha256: 5f80d31c4289ee0cbfa3c8c08872467fb0d121fe2a5ac90ba8af31f7eb97c575

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

# encoding: utf-8

require 'one_apm/transaction/sample_buffer/transaction_sample_buffer'

module OneApm
  class Transaction
    class DeveloperModeSampleBuffer < TransactionSampleBuffer

      OA_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
        OA_CAPACITY
      end

      def harvest_samples
        OA_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/
          trace.shift
        end
        trace
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
oneapm_rpm-1.4.2 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.4.1 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.4.0 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.3.7 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb
oneapm_rpm-1.3.7.rc1 lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb