class Honeybadger::Util::Stats

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/honeybadger/util/stats.rbs

class Honeybadger::Util::Stats
  def all: () -> untyped
  def load: () -> untyped
  def memory: () -> untyped
end

def all

Experimental RBS support (using type sampling data from the type_fusion project).

def all: () -> untyped

This signature was generated using 1 sample from 1 application.

def all
  { :mem => memory, :load => load }
end

def load

Experimental RBS support (using type sampling data from the type_fusion project).

def load: () -> untyped

This signature was generated using 3 samples from 1 application.

From https://github.com/bloopletech/webstats/blob/master/server/data_providers/cpu_info.rb
def load
  out = {}
  if HAS_LOAD && (loadavg = run_loadavg)
    out[:one], out[:five], out[:fifteen] = loadavg.split(' ', 4).map(&:to_f)
  end
  out
end

def memory

Experimental RBS support (using type sampling data from the type_fusion project).

def memory: () -> untyped

This signature was generated using 1 sample from 1 application.

From https://github.com/bloopletech/webstats/blob/master/server/data_providers/mem_info.rb
def memory
  out = {}
  if HAS_MEM && (meminfo = run_meminfo)
    out[:total], out[:free], out[:buffers], out[:cached] = meminfo[0..4].map { |l| l =~ /^.*?\: +(.*?) kB$/; ($1.to_i / 1024.0).to_f }
    out[:free_total] = out[:free] + out[:buffers] + out[:cached]
  end
  out
end

def run

def run
  yield
rescue Errno::ENFILE
  # Catch issues like 'Too many open files in system'
  nil
end

def run_loadavg

def run_loadavg
  run { IO.read("/proc/loadavg") }
end

def run_meminfo

def run_meminfo
  run { IO.readlines("/proc/meminfo") }
end