feat: Allow API callers to inject a request-id header#9432
Open
Dhanus3133 wants to merge 5 commits into
Open
Conversation
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.
Why
The API generates a
request_idfor each incoming request and carries it through the message bus into the task workers, so one request can be traced across systems. But the caller can't supply their own id, so an external system (the git-agent over the SDK, or any API user) has no way to tie that activity back to its own side.Closes #559
What changed
X-Infrahub-Request-Idheader, logs it asuser_request_id(separate from the generatedrequest_id), and propagates it through the message bus to worker logs. Backward compatible, empty default.How to test
Checklist
uv run towncrier create ...)Summary by cubic
Let API callers pass a request ID via the
X-Infrahub-Request-Idheader. We log it asuser_request_idand propagate it across the message bus, RPC paths, and git workers for end-to-end traceability.X-Infrahub-Request-Idand stores it asuser_request_idin the log context.user_request_idtoMeta; propagated viaassign_meta,set_log_data,_add_request_idenrichers, and bothnats/rabbitmqadapters (including RPC).user_request_idin all emitted messages.Written for commit 30b0f49. Summary will update on new commits.