Oban defaults to running in :inline mode in the test environment. When it does this, it seems to not actually install the job in the db, so the inserted_at field never gets set. Then handle_job_start runs and it tries to call DateTime.to_iso8601 on nil and gets a failure and the tests fail.
Expected behavior
Primary expectation is that it shouldn't crash. Seems like 3 possible options and from my perspective, any of them would be acceptable.
Make it easier / default / better documented for how to disable opentelemetry_oban in testing config
Default to disabling opentelemetry_oban if running in inline mode
Default "oban.job.inserted_at" to be DateTime.utc_now() if job inserted_at is nil
Additional context
My app-specific fix for this was a version of option 1 which seems to work, but took some investigation and iteration to get to it.
skipped_telemetry = Application.get_env(:appname, :skipped_telemetry, [])
if not Enum.any?(skipped_telemetry, &(&1 == OpentelemetryOban)) do
OpentelemetryOban.setup()
end
Describe the bug
Oban defaults to running in :inline mode in the test environment. When it does this, it seems to not actually install the job in the db, so the inserted_at field never gets set. Then
handle_job_start
runs and it tries to call DateTime.to_iso8601 on nil and gets a failure and the tests fail.Expected behavior
Primary expectation is that it shouldn't crash. Seems like 3 possible options and from my perspective, any of them would be acceptable.
opentelemetry_oban
if running in inline mode"oban.job.inserted_at"
to beDateTime.utc_now()
if job inserted_at is nilAdditional context
My app-specific fix for this was a version of option 1 which seems to work, but took some investigation and iteration to get to it.