class ElasticAPM::Metrics::VM
@api private
def collect
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def collect return if disabled? stat = GC.stat thread_count = Thread.list.count sample = { 'ruby.gc.count': stat[:count], 'ruby.threads': thread_count } (live_slots = stat[:heap_live_slots]) && sample[:'ruby.heap.slots.live'] = live_slots (heap_slots = stat[:heap_free_slots]) && sample[:'ruby.heap.slots.free'] = heap_slots (allocated = stat[:total_allocated_objects]) && sample[:'ruby.heap.allocations.total'] = allocated return sample unless GC::Profiler.enabled? @total_time += GC::Profiler.total_time GC::Profiler.clear sample[:'ruby.gc.time'] = @total_time sample rescue TypeError => e error 'VM metrics encountered error: %s', e debug('Backtrace:') { e.backtrace.join("\n") } @disabled = true nil end
def disabled?
def disabled? @disabled end
def initialize(config)
def initialize(config) @config = config @total_time = 0 @disabled = false end