Fix nested job request_id chaining#59
Merged
Merged
Conversation
When a job enqueues another job from within its execution context, the nested job's enqueue log has no request_id (only ActiveJob tags with the parent job's ID). Previously, this caused nested jobs to lose the request_id trail: - HTTP request (req-123) → JobA (job-a-456) - JobA enqueues JobB → Enqueue log has NO request_id - JobB execution logs couldn't be traced back to req-123 This fix implements request_id chaining through parent jobs: 1. When registering a job enqueue, if the entry has no request_id, check its tags 2. Extract the parent job_id from tags (e.g., ['ActiveJob', 'JobA', 'job-a-456']) 3. Look up the parent job's request_id from State 4. Register the new job with the parent's request_id This works for arbitrarily deep nesting: - HTTP → JobA → JobB → JobC → ... - All jobs trace back to the original HTTP request Changes: - Updated Parser.register_job_enqueue to chain request_id lookups - Added test for 2-level nested jobs (HTTP → JobA → JobB) - Added test for 3-level nested jobs (HTTP → JobA → JobB → JobC) All 98 tests pass with 378 assertions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a job enqueues another job from within its execution context, the nested job's enqueue log has no
request_id(only ActiveJob tags with the parent job's ID).Previously, this caused nested jobs to lose the request_id trail:
Solution
Implement request_id chaining through parent jobs:
request_id, check its tagsjob_idfrom tags (e.g.,['ActiveJob', 'JobA', 'job-a-456'])request_idfrom Staterequest_idThis works for arbitrarily deep nesting:
Changes
Parser.register_job_enqueueto chain request_id lookups through parent jobsTest Results
✅ All 98 tests pass with 378 assertions
All job logs are now correctly grouped under the original HTTP request, regardless of nesting depth! 🎯