Sha256: 243b141db1ce5d8b75172ad6659a420e5a160a132dc5d54cb3bdeb78cb32d2dc

Contents?: true

Size: 641 Bytes

Versions: 12

Compression:

Stored size: 641 Bytes

Contents

require_relative 'base_probe'

module Roqua
  module Probes
    class MonitoringProbe
      include BaseProbe

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

      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

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
roqua-support-0.4.6 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.4.5 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.4.4 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.4.3 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.4.2 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.4.1 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.4.0 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.3.5 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.3.4 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.3.3 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.3.2 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.3.1 lib/roqua/probes/monitoring_probe.rb