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.
This adds a new filter that accepts a
X-Request-Id
header (or alternatively generates a random UUID) for each request, and adds it to SLF4J'sMDC
. Being part of theMDC
allows it to be included in application and audit logs.The request ID is also included in every response, in the form of an
X-Request-ID
header.This behavior allows for easier correlation of operations in the system. Accepting provided request IDs enables correlation even across system boundaries.
Many API gateways, service meshes, and reverse proxies transparently set the
X-Request-Id
header. Among them Enovy (https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers#x-request-id), Apache APISIX (https://apisix.apache.org/docs/apisix/next/plugins/request-id/), and Heroku (https://devcenter.heroku.com/articles/http-request-id).