Class: OneApm::Transaction::DeveloperModeSampleBuffer

Inherits:
TransactionSampleBuffer show all
Defined in:
lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb

Constant Summary collapse

OA_CAPACITY =
100

Constants inherited from TransactionSampleBuffer

TransactionSampleBuffer::OA_NO_SAMPLES, TransactionSampleBuffer::OA_SINGLE_BUFFER_MAX

Instance Attribute Summary

Attributes inherited from TransactionSampleBuffer

#samples

Instance Method Summary collapse

Methods inherited from TransactionSampleBuffer

#allow_sample?, #full?, #initialize, #reset!, #store, #truncate_samples_if_needed

Constructor Details

This class inherits a constructor from OneApm::Transaction::TransactionSampleBuffer

Instance Method Details

#capacityObject



11
12
13
# File 'lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb', line 11

def capacity
  max_capacity
end

#enabled?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb', line 25

def enabled?
  Manager.config[:developer_mode]
end

#harvest_samplesObject



21
22
23
# File 'lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb', line 21

def harvest_samples
  OA_NO_SAMPLES
end

#max_capacityObject

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



17
18
19
# File 'lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb', line 17

def max_capacity
  OA_CAPACITY
end

#store_previousObject

We don’t hold onto previously trapped transactions on harvest We’ve already got all the traces we want, thank you!



36
37
# File 'lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb', line 36

def store_previous(*)
end

#strip_oneapm_frames(trace) ⇒ Object



49
50
51
52
53
54
# File 'lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb', line 49

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

#truncate_samplesObject

Truncate to the last capacity samples we’ve received



30
31
32
# File 'lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb', line 30

def truncate_samples
  @samples = @samples.last(capacity)
end

#visit_segment(segment) ⇒ Object

Captures the stack trace for a segment This is expensive and not for production mode



41
42
43
44
45
46
47
# File 'lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb', line 41

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