Module: Sentry::Sidekiq::Cron::Job

Defined in:
lib/sentry/sidekiq/cron/job.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.enqueueing_methodObject



15
16
17
# File 'lib/sentry/sidekiq/cron/job.rb', line 15

def self.enqueueing_method
  ::Sidekiq::Cron::Job.instance_methods.include?(:enque!) ? :enque! : :enqueue!
end

Instance Method Details

#finish_transaction(transaction, status_code) ⇒ Object



73
74
75
76
77
78
# File 'lib/sentry/sidekiq/cron/job.rb', line 73

def finish_transaction(transaction, status_code)
  return unless transaction

  transaction.set_http_status(status_code)
  transaction.finish
end

#saveObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/sentry/sidekiq/cron/job.rb', line 41

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.to_s,
                     monitor_config: Sentry::Cron::MonitorConfig.from_crontab(parsed_cron.original))
  end

  true
end

#start_transaction(scope) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/sentry/sidekiq/cron/job.rb', line 64

def start_transaction(scope)
  Sentry.start_transaction(
    name: scope.transaction_name,
    source: scope.transaction_source,
    op: "queue.sidekiq-cron",
    origin: "auto.queue.sidekiq.cron"
  )
end