Class: Upfluence::Instrumentation::GCInstrumenter

Inherits:
PeriodicInstrumenter show all
Defined in:
lib/upfluence/instrumentation/gc_instrumenter.rb

Constant Summary collapse

KEYS =
i[
  heap_live_slots heap_free_slots major_gc_count minor_gc_count
  total_allocated_objects
].freeze

Instance Method Summary collapse

Methods inherited from PeriodicInstrumenter

#initialize, #start, #stop

Constructor Details

This class inherits a constructor from Upfluence::Instrumentation::PeriodicInstrumenter

Instance Method Details

#metricsObject



15
16
17
18
19
# File 'lib/upfluence/instrumentation/gc_instrumenter.rb', line 15

def metrics
  KEYS.reduce({}) do |acc, k|
    acc.merge(k => { docstring: "Gauge for #{k}" })
  end
end

#prefixObject



11
12
13
# File 'lib/upfluence/instrumentation/gc_instrumenter.rb', line 11

def prefix
  'ruby_gc'
end

#valuesObject



21
22
23
24
25
# File 'lib/upfluence/instrumentation/gc_instrumenter.rb', line 21

def values
  GC.stat.slice(*KEYS).reduce({}) do |acc, (k, v)|
    acc.merge(k => [{ value: v }])
  end
end