Class: MemoryTracker::Stores::GcstatLogfileStore

Inherits:
Base
  • Object
show all
Defined in:
lib/memory_tracker/stores/gcstat_logfile_store.rb

Constant Summary collapse

COLUMNS =
[ :count, :heap_final_num, :heap_free_num, :heap_length, :heap_live_num, :heap_used, :rss, :total_allocated_object, :total_freed_object, :vsize ]

Instance Method Summary collapse

Methods inherited from Base

#name, register_store

Constructor Details

#initialize(opts) ⇒ GcstatLogfileStore

Returns a new instance of GcstatLogfileStore.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/memory_tracker/stores/gcstat_logfile_store.rb', line 8

def initialize(opts)
  logger_class = opts.fetch(:logger_class, 'Logger')
  filename     = opts.fetch(:filename, "#{Rails.root}/log/memtracker_gcstat.log")

  @logger = logger_class.constantize.new(filename)
  if @logger.respond_to?(:formatter)
    @logger.formatter = proc do |severity, datetime, progname, msg|
      "#{msg}\n"
    end
  end

  @num_lines = 0
end

Instance Method Details

#push(request) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/memory_tracker/stores/gcstat_logfile_store.rb', line 22

def push(request)
  @request = request

  write_header if @num_lines % 1000 == 0
  write_request_log
  @num_lines += 1
end

#statsObject



30
31
# File 'lib/memory_tracker/stores/gcstat_logfile_store.rb', line 30

def stats
end