Propagate correlation ID when proxying requests to another registry
Problem
In !376 (merged) we're implementing a feature to enable proxying requests that target new repositories to another registry (#218 (closed)). Currently, the only way to correlate requests across the two registry instances is by looking at the log messages that tell whether or not a request was proxied for a repository x
.
This is a followup from !376 (comment 457557360).
Solution
Investigate the possibility of propagating a correlation ID across the two registry instances, linking related requests when these are proxied from the main instance to the secondary one.
This should be possible by:
-
Within the proxy logic (main/left registry), extract the correlation ID from the request. We use LabKit's correlation to generate and embed a correlation ID on each incoming HTTP request (source);
-
Before proxying the request to the new/right registry, add a
X-Request-ID
header, set to the correlation ID extracted from the previous step; -
Although we don't use it at the moment, LabKit allows us to reuse an
X-Request-ID
header value as correlation ID, if one is found in the incoming request (instead of generating a new one). All that we have to do is enable theWithPropagation
option.
Once done, the correlation ID generated by the main/left registry should be propagated to the new/right registry. This is visible in the registry logs, where a correlation_id
key/value pair is shown for each HTTP request.