feat(server): add request-ID middleware for request correlation#1082
Open
sauagarwa wants to merge 1 commit intoNVIDIA:mainfrom
Open
feat(server): add request-ID middleware for request correlation#1082sauagarwa wants to merge 1 commit intoNVIDIA:mainfrom
sauagarwa wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
|
All contributors have signed the DCO ✍️ ✅ |
Add a UUID-based request-ID middleware using tower-http's request-id feature. Each inbound request receives a unique x-request-id header (or preserves a client-supplied one), which is recorded in the tracing span and propagated to the response. This enables operators to correlate log lines across the middleware stack for a single request under concurrent load, and lets clients reference specific requests in bug reports. Signed-off-by: sauagarwa <sauagarw@redhat.com>
942d293 to
d7f49b2
Compare
Author
|
I have read the DCO document and I hereby sign the DCO. recheck |
Author
|
recheck |
Author
|
I have read the DCO document and I hereby sign the DCO. |
Author
|
recheck |
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.
Summary
Add request-ID middleware to the gateway server so every request carries a unique, traceable identifier. Uses
tower-http'sSetRequestIdLayerandPropagateRequestIdLayerwith UUID v4 generation, recording the ID in the tracing span and returning it in thex-request-idresponse header. Client-supplied IDs are preserved (no overwrite).Related Issue
Closes #932
Changes
Cargo.toml: Enablerequest-idfeature on thetower-httpworkspace dependencycrates/openshell-server/src/multiplex.rs:UuidRequestIdstruct implementingMakeRequestId(UUID v4 via existinguuidcrate)make_request_spanto extract and recordx-request-idin the tracing spanrequest_id_middleware!macro for consistent layer ordering:SetRequestId→TraceLayer→PropagateRequestIdMultiplexService::serve()crates/openshell-server/tests/multiplex_integration.rs:grpc_response_propagates_request_idintegration test verifying tonic metadata ↔ HTTP header roundtrip for both server-generated and client-supplied request IDsLog output before
Log output after
Testing
mise run pre-commitpassesmultiplex::tests)grpc_response_propagates_request_id)cargo test -p openshell-serverpasses (353 tests, 0 failures)Checklist