Bootstraps an initial http client implementation for Labkit
This contains a fairly rudimentary implementation of a HTTP client that adheres to Go's net/http Client interface. This is important as it'll allow for far more straightforward adoption of this library as it should just be a case of swapping out imports.
This will then allow us to incrementally roll out the adoption of the extended Do method that accepts the context struct. This will then allow us to ensure that correlation_id propagation is being done on the outbound requests in situations where the correlation_id is present within said context.
The hope is that, as adoption of the Labkit-based HTTP client grows, the cases where the correlation_id are not present become the exception to the rule.
The main use case I'd like to address is:
- Something calls any GitLab service with a
correlation_idin the request headers. - LabKit-based o11y middleware will extract this
correlation_id(and potentiallytraceparentheaders) out and place them into the context, and the request will continue execution through the service. -
httpcl.NewClientis called to construct a new client (Gitaly use case), or an existing client is used if we're dealing with a standard application that has one instantiated at startup. - The application then calls
httpClient.Do(req)and the LabKit logic will automagically extract thecorrelation_idetc. from thecontextand enrich the outgoing request.- Note: We will need to ensure linting rules are in place that mean all requests are instantiated using the
NewRequestWIthContextmethod that is built into the Go standard library
- Note: We will need to ensure linting rules are in place that mean all requests are instantiated using the
Epic Link:
Edited by Elliot Forbes