Sha256: 0b2ce8fe3b77ec5b337654b14be3ca9f1ecb8768991cc5b77f9ebc2407f58e0e

Contents?: true

Size: 1.14 KB

Versions: 14

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

# Try requiring sidekiq-cron to ensure it's loaded before the integration.
# If sidekiq-cron is not available, do nothing.
begin
  require "sidekiq-cron"
rescue LoadError
  return
end

module Sentry
  module Sidekiq
    module Cron
      module Job
        def save
          # validation failed, do nothing
          return false unless super

          # fail gracefully if can't find class
          klass_const =
            begin
              ::Sidekiq::Cron::Support.constantize(klass.to_s)
            rescue NameError
              return true
            end

          # only patch if not explicitly included in job by user
          unless klass_const.send(:ancestors).include?(Sentry::Cron::MonitorCheckIns)
            klass_const.send(:include, Sentry::Cron::MonitorCheckIns)
            klass_const.send(:sentry_monitor_check_ins,
                             slug: name,
                             monitor_config: Sentry::Cron::MonitorConfig.from_crontab(cron))
          end

          true
        end
      end
    end
  end
end

Sentry.register_patch(:sidekiq_cron, Sentry::Sidekiq::Cron::Job, ::Sidekiq::Cron::Job)

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
sentry-sidekiq-5.19.0 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.18.2 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.18.1 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.18.0 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.17.3 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.17.2 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.17.1 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.17.0 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.16.1 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.16.0 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.15.2 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.15.1 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.15.0 lib/sentry/sidekiq/cron/job.rb
sentry-sidekiq-5.14.0 lib/sentry/sidekiq/cron/job.rb