Skip to content

Commit ce93ed4

Browse files
authored
Add timezone to Quantum check-ins (#860)
1 parent 8b97936 commit ce93ed4

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lib/sentry/integrations/quantum/cron.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ defmodule Sentry.Integrations.Quantum.Cron do
7070
check_in_id: id,
7171
# This is already a binary.
7272
monitor_slug: "quantum-#{slugify(job.name)}",
73-
monitor_config: [schedule: schedule_opts]
73+
monitor_config: [schedule: schedule_opts, timezone: timezone_to_string(job)]
7474
]
7575
else
7676
nil
@@ -97,6 +97,11 @@ defmodule Sentry.Integrations.Quantum.Cron do
9797
|> Kernel./(1000)
9898
end
9999

100+
defp timezone_to_string(%{timezone: :utc}), do: "Etc/UTC"
101+
defp timezone_to_string(%{timezone: nil}), do: "Etc/UTC"
102+
defp timezone_to_string(%{timezone: timezone}), do: timezone
103+
defp timezone_to_string(_job_without_timezone_key_for_some_reason), do: "Etc/UTC"
104+
100105
defp slugify(job_name) when is_reference(job_name) do
101106
Logger.error(
102107
"""

test/sentry/integrations/quantum/cron_test.exs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ defmodule Sentry.Integrations.Quantum.CronTest do
6767
"schedule" => %{
6868
"type" => "crontab",
6969
"value" => "0 0 * * * *"
70-
}
70+
},
71+
"timezone" => "Etc/UTC"
7172
}
7273

7374
send(test_pid, {ref, :done})
@@ -108,7 +109,8 @@ defmodule Sentry.Integrations.Quantum.CronTest do
108109
"schedule" => %{
109110
"type" => "crontab",
110111
"value" => "0 0 * * * *"
111-
}
112+
},
113+
"timezone" => "Europe/Rome"
112114
}
113115

114116
send(test_pid, {ref, :done})
@@ -122,7 +124,8 @@ defmodule Sentry.Integrations.Quantum.CronTest do
122124
job:
123125
Scheduler.new_job(
124126
name: :test_job,
125-
schedule: Crontab.CronExpression.Parser.parse!("@daily")
127+
schedule: Crontab.CronExpression.Parser.parse!("@daily"),
128+
timezone: "Europe/Rome"
126129
),
127130
telemetry_span_context: ref
128131
})
@@ -151,7 +154,8 @@ defmodule Sentry.Integrations.Quantum.CronTest do
151154
"schedule" => %{
152155
"type" => "crontab",
153156
"value" => "0 0 * * * *"
154-
}
157+
},
158+
"timezone" => "Etc/UTC"
155159
}
156160

157161
send(test_pid, {ref, :done})

0 commit comments

Comments
 (0)