Skip to content

crontabs with "@reboot" oban option instead of valid crontab cause sentry logger to fail and detach #934

@markquezada

Description

@markquezada

Issue Description

This took a bit to track down but Oban allows a @reboot option to run a job in the crontab at boot.

I would see this randomly in the logs after boot and my cron monitors would start failing:

[error] Handler Sentry.Integrations.Oban.Cron has failed and has been detached. Class=:error
Reason={:badkey, :schedule}
Stacktrace=[
  {:erlang, :map_get, [:schedule, %{timezone: "Etc/UTC"}],
   [error_info: %{module: :erl_erts_errors}]},
  {Map, :update!, 3, [file: ~c"lib/map.ex", line: 318]},
  {Sentry.CheckIn, :new, 1, [file: ~c"lib/sentry/check_in.ex", line: 181]},
  {Sentry, :capture_check_in, 1, [file: ~c"lib/sentry.ex", line: 438]},
  {Sentry.Integrations.Oban.Cron, :handle_event, 4,
   [file: ~c"lib/sentry/integrations/oban/cron.ex", line: 46]},
  {:telemetry, :"-execute/3-fun-0-", 4,
   [
     file: ~c"../deps/telemetry/src/telemetry.erl",
     line: 167
   ]},
  {:lists, :foreach_1, 2, [file: ~c"lists.erl", line: 2310]},
  {Oban.Queue.Executor, :record_started, 1,
   [file: ~c"lib/oban/queue/executor.ex", line: 97]},
  {Oban.Queue.Executor, :call, 1,
   [file: ~c"lib/oban/queue/executor.ex", line: 73]},
  {Task.Supervised, :invoke_mfa, 2,
   [file: ~c"lib/task/supervised.ex", line: 101]},
  {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}
]

I tracked this down to the @reboot option. My guess is that since it doesn't have an actual schedule associated with it, the option wouldn't get set in the logger config.

Reproduction Steps

Use @reboot option as the crontab schedule

Expected Behavior

I assume any @reboot schedules should not be monitored since they don't actually run on a schedule

Actual Behavior

The logger detaches an cron monitoring is disabled

Elixir Version

Elixir 1.18.1

SDK Version

11.0.2

Integration and Its Version

Oban 2.19.4

Sentry Config

config :sentry,
  enable_source_code_context: true,
  root_source_code_paths: [File.cwd!()],
  client: MyApp.Sentry.FinchHTTPClient,
  before_send: {MyApp.Sentry.EventProcessor, :process},
  integrations: [
    oban: [
      capture_errors: true,
      cron: [enabled: true]
    ]
  ]

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions