procrastinate icon indicating copy to clipboard operation
procrastinate copied to clipboard

Add error message context to failure

Open StephenOTT opened this issue 1 year ago • 2 comments

When a job/task fails the logs contain what happened, but often you want to add a error message/explanation as part of the log

Is there a way to do this?

At first glance it would seem a json col in the events table would work and allow submitting "context" info as part of the job attempt/fail

Thanks

StephenOTT avatar Oct 31 '24 11:10 StephenOTT

https://procrastinate.readthedocs.io/en/stable/howto/production/logging.html#make-the-most-out-of-the-logging-system

Does the above section help?

In the case of a failed job, there would be an exc_info atttribute in the extra field that holds the caught exception.

Another way is to define a middleware and catch/re-raise exceptions there.

At first glance it would seem a json col in the events table would work and allow submitting "context" info as part of the job attempt/fail

I can see how it would be useful to have error context persisted for failed job events.

onlyann avatar Nov 03 '24 07:11 onlyann

I think it would make sense to have that if we also have task results (which would make sense if we had workflows).

It might be worth revisiting the whole thing, but I think this needs a design decision for the vision of Procrastinate before we make it a thing especially since that can be implemented as user code.

ewjoachim avatar Jan 18 '25 15:01 ewjoachim