Class: Refinery::Statistics

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/refinery/statistics.rb

Overview

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).

Instance Method Summary collapse

Methods included from Loggable

#logger

Instance Method Details

#record_done(message) ⇒ Object

Record the done record into the



9
10
11
12
13
14
15
16
17
# File 'lib/refinery/statistics.rb', line 9

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_error(message) ⇒ Object

Record the error message into the statistics database.



20
21
22
23
24
25
26
27
28
29
# File 'lib/refinery/statistics.rb', line 20

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