Sha256: 31d21ce1d9ae1ed5377d585a8d310e3a612b65c206e0c57d06c6f3b22e487020
Contents?: true
Size: 1.82 KB
Versions: 52
Compression:
Stored size: 1.82 KB
Contents
module Refinery #:nodoc: # The statistics class provides a means to record runtime stats # about completed jobs and errors. The stats are stored in a SQL # database (using SQLite3 by default). class Statistics include Refinery::Loggable # Record the done record into the def record_done(message) db[:completed_jobs] << { :host => message['host_info']['hostname'], :pid => message['host_info']['pid'], :run_time => message['run_time'], :original_message => message['original'], :when => Time.now } end # Record the error message into the statistics database. def record_error(message) db[:errors] << { :host => message['host_info']['hostname'], :pid => message['host_info']['pid'], :error_class => message['error']['class'], :error_message => message['error']['message'], :original_message => message['original'], :when => Time.now } end private # Get a Sequel connection to the stats database def db @db ||= begin db = Sequel.connect('sqlite://stats.db') unless db.table_exists?(:completed_jobs) db.create_table :completed_jobs do primary_key :id column :host, :text column :pid, :integer column :run_time, :float column :original_message, :text column :when, :time end end unless db.table_exists?(:errors) db.create_table :errors do primary_key :id column :host, :text column :pid, :integer column :error_class, :text column :error_message, :text column :original_message, :text column :when, :time end end db end end end end
Version data entries
52 entries across 52 versions & 2 rubygems