HTTPClient: verbose logs for request IDs (#3320)

See https://github.com/RevenueCat/khepri/pull/6798.
This can help debug issues as it helps us cross-reference requests on
our end.

### Changes:
- Logging `X-Request-ID` and `X-Amzn-Trace-ID` headers if present (only
in verbose mode)
- Logging these even for failed requests
- Also logging `request_handled_by_load_shedder` for failed requests
- To accomplish that. `HTTPURLResponse` now conforms to our
`HTTPResponseType`, this allows us to extract headers in an uniform way

### Example:
```
[network] DEBUG: ℹ️ API request completed: GET '/v1/subscribers/$RCAnonymousID%3Ad9dc4f3b33054cf28c0f2ec9da0f48d5' (304)
Request-ID: 'be534c50-5231-403b-be2f-7c077861751d'; Amzn-Trace-ID: 'Root=1-6532c6ca-7ef80f961ec9c4145484df13'
```
This commit is contained in:
NachoSoto authored and GitHub committed 2023-10-25 20:24:23 -07:00
1 parent 38b4e3b411
commit ed80980d08
19 files changed
+161 -83

No files matched your search

@@ -101,13 +101,3 @@ extension HTTPStatusCode {
}
}
extension URLResponse {
var httpStatusCode: HTTPStatusCode? {
guard let response = self as? HTTPURLResponse else { return nil }
return .init(rawValue: response.statusCode)
}
}