Module: GreenHat::Sidekiq

Defined in:
lib/greenhat/accessors/logs/sidekiq.rb

Overview

Sidekiq Log Helpers

Class Method Summary collapse

Class Method Details

.errorsObject



24
25
26
# File 'lib/greenhat/accessors/logs/sidekiq.rb', line 24

def self.errors
  logs.select { |x| x.severity == 'ERROR' }
end

.fast_statsObject



4
5
6
7
8
9
10
# File 'lib/greenhat/accessors/logs/sidekiq.rb', line 4

def self.fast_stats
  things.each do |thing|
    puts `fast-stats #{thing.file}`
  end

  :ok!
end

.logsObject



12
13
14
# File 'lib/greenhat/accessors/logs/sidekiq.rb', line 12

def self.logs
  @logs ||= things.map(&:data).flatten.compact
end

.pagesObject



28
29
30
# File 'lib/greenhat/accessors/logs/sidekiq.rb', line 28

def self.pages
  show logs
end

.queue_duration(data = nil) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/greenhat/accessors/logs/sidekiq.rb', line 32

def self.queue_duration(data = nil)
  data ||= logs
  data.select { |x| x.key? :enqueued_at }.each do |row|
    next if row.key? :queue_duration

    row[:queue_duration] = row.enqueued_at - row.created_at
  end
end

.rawObject



16
17
18
# File 'lib/greenhat/accessors/logs/sidekiq.rb', line 16

def self.raw
  @raw ||= things.map(&:raw).flatten.compact
end

.thingsObject



20
21
22
# File 'lib/greenhat/accessors/logs/sidekiq.rb', line 20

def self.things
  Thing.where(name: 'sidekiq_current')
end