class SidekiqLogAnalyser::Row

Attributes

end_match[R]
row[R]
start_match[R]

Public Class Methods

new(row) click to toggle source
# File lib/sidekiq_log_analyser/row.rb, line 5
def initialize(row)
  @row         = "#{row}"
  @start_match = @row.match(/(.*Z) (.*) (T.*) (J.*) INFO: start/)
  @end_match   = @row.match(/(.*Z) (.*) (T.*) (J.*) INFO: done: (.*) sec/)
end

Public Instance Methods

end?() click to toggle source
# File lib/sidekiq_log_analyser/row.rb, line 15
def end?
  end_match != nil && end_match.length > 0
end
metadata() click to toggle source
# File lib/sidekiq_log_analyser/row.rb, line 23
def metadata
  @metadata ||= begin
    if start?
      {
        datetime: Time.parse(start_match[1]),
        worker: start_match[3].split(' ').last,
        job_id: start_match[4],
        type: :start
      }
    elsif end?
      {
        datetime:  Time.parse(end_match[1]),
        worker: end_match[3].split(' ').last,
        job_id: end_match[4],
        duration: end_match[5].to_f,
        type: :end
      }
    else
      {}
    end
  end
end
start?() click to toggle source
# File lib/sidekiq_log_analyser/row.rb, line 11
def start?
  start_match != nil && start_match.length > 0
end
valid?() click to toggle source
# File lib/sidekiq_log_analyser/row.rb, line 19
def valid?
  start? || end?
end