hashicorp / hashicorp/terraform-plugin-log
Consider tflog http.Transport Implementation
- Dominant language
- Go
- Stars
- 23
- Forks
- 11
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 1
Description
### terraform-plugin-log version
```
v0.7.0
```
### Use cases
terraform-plugin-sdk/v2 was recently updated to include a new [`tflog` based `http.Transport` implementation](https://www.terraform.io/plugin/sdkv2/logging/http-transport) to replace the Go standard library `log` based one. Given that this code enhances/configures Go standard library functionality, is tightly coupled to terraform-plugin-log, and doesn't necessarily apply to just terraform-plugin-sdk, it might make sense to include it in this module as well.
### Attempted solutions
Import and use terraform-plugin-sdk implementation or manually recreate it.
### Proposal
Introduce a new `tfhttplog` (or `tfloghttp` or `tflog/tfhttplog`) package, which contains the following:
- Ability to get a `tflog` ready `http.Transport` (e.g. support `http.Client{Transport: XXX}` directly)
- Ability to get just the `tflog` logic for `http.Request` logging (e.g. support [go-retryablehttp.Client.RequestLogHook](https://pkg.go.dev/github.com/hashicorp/go-retryablehttp#Client.RequestLogHook))
- Ability to get just the `tflog` logic for `http.Response` logging (e.g. support [go-retryablehttp.Client.ResponseLogHook](https://pkg.go.dev/github.com/hashicorp/go-retryablehttp#Client.ResponseLogHook))
The latter two may also necessitate the need for something to create/handle HTTP transaction IDs (or a guided way for the consumer to inject their own), since that is something baked into the `http.Transport` itself currently.
When creating the website documentation for this functionality, it might be useful to provide examples for how to use it with `go-retryablehttp`.
### References
- https://pkg.go.dev/net/http#Transport
- https://pkg.go.dev/github.com/hashicorp/go-retryablehttp#Client
- https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging#NewLoggingHTTPTransport
- https://github.com/hashicorp/terraform-providers-devex-internal/issues/122
- https://github.com/hashicorp/terraform-provider-http/pull/151
Contributor guide
Assessment
This issue has not been assessed yet.