Sha256: 8816ef5d9a92dc71c7af274742129de82a4ea40d5614c8554eb2f9ed025586db

Contents?: true

Size: 1.41 KB

Versions: 8

Compression:

Stored size: 1.41 KB

Contents

module RequestLogAnalyzer::FileFormat

  # The DelayedJob21 file format parsed log files that are created by DelayedJob 2.1 or higher.
  # By default, the log file can be found in RAILS_ROOT/log/delayed_job.log
  class DelayedJob21 < Base
    
    extend CommonRegularExpressions
    
    line_definition :job_lock do |line|
      line.header = true
      line.regexp = /(#{timestamp('%Y-%m-%dT%H:%M:%S%z')}): \[Worker\(\w+ host:(\S+) pid:(\d+)\)\] acquired lock on (\S+)/
      
      line.capture(:timestamp).as(:timestamp)
      line.capture(:host)
      line.capture(:pid).as(:integer)
      line.capture(:job)
    end
    
    line_definition :job_completed do |line|
      line.footer = true
      line.regexp = /(#{timestamp('%Y-%m-%dT%H:%M:%S%z')}): \[Worker\(\w+ host:(\S+) pid:(\d+)\)\] (\S+) completed after (\d+\.\d+)/
      line.capture(:timestamp).as(:timestamp)
      line.capture(:host)
      line.capture(:pid).as(:integer)
      line.capture(:job)
      line.capture(:duration).as(:duration, :unit => :sec)
    end
    
    report do |analyze|
      analyze.timespan
      analyze.hourly_spread

      analyze.frequency :job, :line_type => :job_completed, :title => "Completed jobs"
      #analyze.frequency :job, :if => lambda { |request| request[:attempts] ==  1 }, :title => "Failed jobs"
      
      analyze.duration :duration, :category => :job, :line_type => :job_completed, :title => "Job duration"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
request-log-analyzer-1.9.7 lib/request_log_analyzer/file_format/delayed_job21.rb
request-log-analyzer-1.9.6 lib/request_log_analyzer/file_format/delayed_job21.rb
request-log-analyzer-1.9.5 lib/request_log_analyzer/file_format/delayed_job21.rb
request-log-analyzer-1.9.4 lib/request_log_analyzer/file_format/delayed_job21.rb
request-log-analyzer-1.9.3 lib/request_log_analyzer/file_format/delayed_job21.rb
request-log-analyzer-1.9.2 lib/request_log_analyzer/file_format/delayed_job21.rb
request-log-analyzer-1.9.1 lib/request_log_analyzer/file_format/delayed_job21.rb
request-log-analyzer-1.9.0 lib/request_log_analyzer/file_format/delayed_job21.rb