Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions lib/sentry/integrations/oban/cron.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,26 @@ defmodule Sentry.Integrations.Oban.Cron do
end

defp job_to_check_in_opts(job, config) when is_struct(job, Oban.Job) do
monitor_config_opts = Sentry.Config.integrations()[:monitor_config_defaults]
monitor_config_opts = maybe_put_timezone_option(monitor_config_opts, job)
# Check schedule first - if empty (e.g., @reboot), skip check-in entirely
# since @reboot can't be expressed as a cron/interval schedule
case schedule_opts(job) do
[] ->
nil

monitor_slug =
case config[:monitor_slug_generator] do
nil ->
slugify(job.worker)
schedule_opts ->
monitor_config_opts = Sentry.Config.integrations()[:monitor_config_defaults]
monitor_config_opts = maybe_put_timezone_option(monitor_config_opts, job)
monitor_config_opts = Keyword.merge(monitor_config_opts, schedule_opts)

{mod, fun} when is_atom(mod) and is_atom(fun) ->
mod |> apply(fun, [job]) |> slugify()
end
monitor_slug =
case config[:monitor_slug_generator] do
nil ->
slugify(job.worker)

case Keyword.merge(monitor_config_opts, schedule_opts(job)) do
[] ->
nil
{mod, fun} when is_atom(mod) and is_atom(fun) ->
mod |> apply(fun, [job]) |> slugify()
end

monitor_config_opts ->
id = CheckInIDMappings.lookup_or_insert_new(job.id)

opts = [
Expand Down
13 changes: 13 additions & 0 deletions test/sentry/integrations/oban/cron_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ defmodule Sentry.Integrations.Oban.CronTest do
})
end

test "ignores #{event_type} events with a cron expr of @reboot even with timezone", %{
bypass: bypass
} do
Bypass.down(bypass)

:telemetry.execute([:oban, :job, unquote(event_type)], %{}, %{
job: %Oban.Job{
worker: "Sentry.MyWorker",
meta: %{"cron" => true, "cron_expr" => "@reboot", "cron_tz" => "Etc/UTC"}
}
})
end

test "ignores #{event_type} events with a cron expr that is not a string", %{bypass: bypass} do
Bypass.down(bypass)

Expand Down
Loading