feat(http): add http.client.log for logging outgoing HTTP requests#4337
Open
reinkrul wants to merge 3 commits into
Open
feat(http): add http.client.log for logging outgoing HTTP requests#4337reinkrul wants to merge 3 commits into
reinkrul wants to merge 3 commits into
Conversation
Adds a configurable log level for outgoing HTTP requests/responses made by the node, mirroring http.log for incoming traffic. Reuses the existing http.LogLevel enum (nothing/metadata/metadata-and-body) and defaults to nothing. Wired up in http.configureClient() via a transport-wrapping hook on the http client package. Assisted by AI
The logging transport wrapper was decided when the HTTP client was created. Engines that build their clients before the HTTP engine is configured (e.g. auth's OpenID4VCI client) never got the wrapper, since client.RequestLogger was still nil at construction. The HTTP engine is registered/configured last, so http.client.log had no effect on those clients. Always install a thin loggingTransport indirection in getTransport that reads RequestLogger per request, mirroring how StrictMode is read at request time. Clients created before logging is configured now log. Assisted by AI
Contributor
0 new issues
|
Contributor
|
Coverage Impact ⬆️ Merging this pull request will increase total coverage on Modified Files with Diff Coverage (5)
🤖 Increase coverage with AI coding...🚦 See full report on Qlty Cloud » 🛟 Help
|
Make the log level the single control instead of also depending on the global debug verbosity: - Log request and response headers at both 'metadata' and 'metadata-and-body' (previously headers required debug verbosity). - Mask credential-bearing request headers (Authorization, Proxy-Authorization) so they don't leak into the logs. Response WWW-Authenticate is a challenge, not a credential, so it is not masked. Assisted by AI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds a configurable log level for outgoing HTTP requests/responses made by the node, mirroring the existing
http.log(which logs incoming/server-side traffic). Reuses the existinghttp.LogLevelenum and defaults tonothing(no change in behavior unless explicitly enabled).New config option
http.client.log:nothing(default)metadatametadata-and-bodyAt debug verbosity, request headers are also logged.
How it works
http.configureClient()via aclient.RequestLoggerhook on thehttp/clientpackage (same injection pattern asclient.StrictMode).getTransportnow always installs a thinloggingTransportindirection that consultsRequestLoggerper request.isLoggableContentTypefilter (JSON-family content types), so binary payloads aren't dumped.Notes
application/json,application/did+json,application/vc+json,application/x-www-form-urlencoded.HTTP client request failedline only appears for connection-level errors (refused/TLS/timeout/strict-mode rejection).Out of scope (flagged, not changed)
The server-side request logger checks
logger.Level >= logrus.DebugLevelon a*logrus.Entry(http/requestlogger.go).Entry.Levelis always0(panic level), so that "log headers at debug" path is effectively dead. The new client logger uses the correctlogger.Logger.Level. Server-side left untouched to keep this diff tight; worth a follow-up.Tests
clientlogger_test.go— metadata-only, metadata-and-body, non-loggable content type, debug headers, transport error.client_test.go— regression: client created beforeRequestLoggeris set still logs.engine_test.go—configureClientwiring per level.Assisted by AI