Add job_id and exception message to ActiveJob retry/discard logging - #42990
Conversation
|
I'm sorry I don't understand what to do with that build failure, I think it's unrelated? I am not familiar with this build system (I think Rails has changed it since I last looked at a Rails CI), but I think maybe actual automated tests were run anyway and green? Not sure. The error I can find in build output is related to npm/webpacker, and my PR touched nothing related to JS, so. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
|
I would still love for this to be considered for merge. Will rebase. |
1eb6a8d to
b260bb8
Compare
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
|
I would still love to see this reviewed/merged, I think it is a pretty simple improvement to ActiveJob logging to make it more internally consistent and predictable. I have had to monkey-patch my own Rails to add it; I think all would benefit from it. I guess I'm just gonna keep posting that everytime rails bot tries to mark it stale! |
I wonder if it would be practical for us to solve it at this layer (i.e., by arranging to tag those log messages). I imagine people who parse and group logs based on tags during ingestion into some log system might prefer that consistency. 🤔 Failure looks real:
|
b260bb8 to
ab11ee5
Compare
In other log messages like perform/performed and ActiveJob error logging, the job ID and exception message were already included, eg:
Error performing TestFailureJob (Job ID: d70ad13e-e58b-409c-a8cc-e0447fc792b5) from Resque(default) in 1446.56ms: RuntimeError (Error Message):
But log message related to retry/discard behavior from ActiveJob::Exceptions did not include the Job ID or exception message. We now include them, in a consistent format with other existing messages.
Job ID is especially useful because, while other ActiveJob-related log messages get the Job ID via tagged logging, retry-related log messages do not currently end up tagged with Job ID. And it's really useful to use Job ID to be able to collect all the log lines related to a particular job, put the error messages together with the retry and subsequent perform messages.
We also include job.executions in the enqueue_retry log message because it was available and useful, to know if this is the 1st retry or 2nd or whatever. Previously job.executions was included in retry_stopped logging, but not enqueue_retry.
ab11ee5 to
dcce260
Compare
|
Thanks so much for feedback @matthewd ! I have fixed the typo error caught by CI now that it was working! And rebased on main branch -- build is now green!
It does sound like a good solution to get ActiveJob logging to automatically tag with "Job ID". it's a bit beyond my knowledge/energy to do that at present. The logging was already including JobID in some log messages but not others; this PR keeps the same architecture that was there before without adding/changing anything, just makes all log messages consistent with info and formatting. Perhaps that's a reasonable step. |
Yep, fair point 👍🏻 Thanks! (And thanks for persevering through the silence) |
|
Thank you @matthewd ! |
In other log messages like perform/performed and ActiveJob error logging, the job ID and exception message were already included, eg:
But log messages related to retry/discard behavior from ActiveJob::Exceptions did not include the Job ID or exception message. We now include them, in a consistent format with other existing messages.
Job ID is especially useful because, while other ActiveJob-related log messages get the Job ID via tagged logging, retry-related log messages do not currently end up tagged with Job ID. And it's really useful to use Job ID to be able to collect all the log lines related to a particular job, put the error messages together with the retry and subsequent perform messages.
We also include job.executions in the enqueue_retry log message because it was available and useful, to know if this is the 1st retry or 2nd or whatever. Previously job.executions was included in retry_stopped logging, but not enqueue_retry.