# 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