17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/sentry/sidekiq-scheduler/scheduler.rb', line 17
def new_job(name, interval_type, config, schedule, options)
rufus_job = super
klass = config.fetch("class")
return rufus_job unless klass
klass_const =
begin
Object.const_get(klass)
rescue NameError
return rufus_job
end
monitor_config =
case interval_type
when "cron"
parsed_cron = ::Fugit.parse_cron(schedule)
timezone = parsed_cron.timezone
if timezone
parsed_cron.instance_variable_set(:@timezone, nil)
cron_without_timezone = parsed_cron.to_cron_s
Sentry::Cron::MonitorConfig.from_crontab(cron_without_timezone, timezone: timezone.name)
else
Sentry::Cron::MonitorConfig.from_crontab(schedule)
end
when "every", "interval"
Sentry::Cron::MonitorConfig.from_interval(rufus_job.frequency.to_i / 60, :minute)
end
return rufus_job if monitor_config.nil?
unless klass_const.send(:ancestors).include?(Sentry::Cron::MonitorCheckIns)
klass_const.send(:include, Sentry::Cron::MonitorCheckIns)
slug = klass_const.send(:sentry_monitor_slug, name: name)
klass_const.send(:sentry_monitor_check_ins,
slug: slug,
monitor_config: monitor_config)
::Sidekiq.logger.info "Injected Sentry Crons monitor checkins into #{klass}"
end
rufus_job
end
|