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:

  1. Something calls any GitLab service with a correlation_id in the request headers.
  2. LabKit-based o11y middleware will extract this correlation_id (and potentially traceparent headers) out and place them into the context, and the request will continue execution through the service.
  3. httpcl.NewClient is 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.
  4. The application then calls httpClient.Do(req) and the LabKit logic will automagically extract the correlation_id etc. from the context and enrich the outgoing request.
    1. Note: We will need to ensure linting rules are in place that mean all requests are instantiated using the NewRequestWIthContext method that is built into the Go standard library

Epic Link:

gitlab-org/quality&224

Edited by Elliot Forbes

Merge request reports

Loading