lib/sentry/sidekiq-scheduler/scheduler.rb in sentry-sidekiq-5.15.2 vs lib/sentry/sidekiq-scheduler/scheduler.rb in sentry-sidekiq-5.16.0
- old
+ new
@@ -35,10 +35,22 @@
# For cron, every, or interval jobs — grab their schedule.
# Rufus::Scheduler::EveryJob stores it's frequency in seconds,
# so we convert it to minutes before passing in to the monitor.
monitor_config = case interval_type
when "cron"
- Sentry::Cron::MonitorConfig.from_crontab(schedule)
+ # fugit is a second order dependency of sidekiq-scheduler via rufus-scheduler
+ parsed_cron = ::Fugit.parse_cron(schedule)
+ timezone = parsed_cron.timezone
+
+ # fugit supports having the timezone part of the cron string,
+ # so we need to pull that with some hacky stuff
+ 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
# If we couldn't build a monitor config, it's either an error, or