Class: Roqua::Probes::MonitoringProbe

Inherits:
Object
  • Object
show all
Includes:
BaseProbe
Defined in:
lib/roqua/probes/monitoring_probe.rb

Instance Method Summary collapse

Methods included from BaseProbe

#call

Instance Method Details

#incomplete_jobsObject



8
9
10
# File 'lib/roqua/probes/monitoring_probe.rb', line 8

def incomplete_jobs
  Roqua::Scheduling::CronJob.where('completed_at IS NULL OR completed_at < next_run_at')
end

#longest_delay_in_minutesObject



12
13
14
15
16
17
18
19
20
# File 'lib/roqua/probes/monitoring_probe.rb', line 12

def longest_delay_in_minutes
  delays = incomplete_jobs.pluck(:next_run_at).map do |next_run_at|
    Time.now - next_run_at
  end

  longest_delay_in_seconds = ([0] + delays).max

  (longest_delay_in_seconds / 1.minute).to_i
end

#runObject



22
23
24
# File 'lib/roqua/probes/monitoring_probe.rb', line 22

def run
  Appsignal.set_gauge('scheduler_delay_in_minutes', longest_delay_in_minutes)
end