Sha256: 086e5c026bf34d0048a95fe68ad0a620f00e4bd94385dc7e7872a8b92cc47172

Contents?: true

Size: 641 Bytes

Versions: 7

Compression:

Stored size: 641 Bytes

Contents

require_relative 'base_probe'

module Roqua
  module Probes
    class MonitoringProbe
      extend 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 call
        Appsignal.set_gauge('scheduler_delay_in_minutes', longest_delay_in_minutes)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
roqua-support-0.3.0 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.1.34 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.1.33 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.1.32 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.1.31 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.1.30 lib/roqua/probes/monitoring_probe.rb
roqua-support-0.1.29 lib/roqua/probes/monitoring_probe.rb