perf: skip HTTP body reading when debug logging is disabled#1097
Open
fredericrous wants to merge 4 commits into
Open
perf: skip HTTP body reading when debug logging is disabled#1097fredericrous wants to merge 4 commits into
fredericrous wants to merge 4 commits into
Conversation
makeLogClient() was creating a new http.Client with a cloned transport, which gave it a separate connection pool. This meant TCP+TLS connections were never reused between update cycles. Now wraps the original client's transport with the logging round tripper directly, preserving the connection pool and keep-alive behavior. Fixes #1094 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The loggingRoundTripper was unconditionally reading entire HTTP request/response bodies via io.ReadAll() on every round trip, even at the default Info log level. The expensive work (body read, string conversion, concatenation) happened before Debug() was called, so the logger's internal level check couldn't prevent it. Now makeLogClient skips wrapping the transport entirely when debug logging is not enabled, eliminating all overhead in the common case. Fixes #1096 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
qdm12
reviewed
Apr 10, 2026
qdm12
left a comment
Owner
There was a problem hiding this comment.
Rebase on master/merge on master
Per review feedback: keep makeLogClient with its original signature and conditionally invoke it in NewUpdater instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
qdm12
approved these changes
Apr 11, 2026
| *config.Health.HealthchecksioUUID) | ||
|
|
||
| updater := update.NewUpdater(db, client, shoutrrrClient, logger, timeNow) | ||
| debugEnabled := strings.EqualFold(config.Logger.Level, "DEBUG") |
Owner
There was a problem hiding this comment.
(and import the qdm12/log package in main.go)
Suggested change
| debugEnabled := strings.EqualFold(config.Logger.Level, "DEBUG") | |
| debugEnabled := config.Logger.Level == log.LevelDebug.String() |
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
loggingRoundTripperwas reading entire HTTP request/response bodies viaio.ReadAll()on every round trip, even at the default Info log levelDebug()was called, so the logger's internal level check couldn't prevent itmakeLogClientskips wrapping the transport entirely when debug logging is not enabled — zero overhead in the common caseFixes #1096
Test plan
go build ./...compiles cleanlygo test ./...— all tests passLOG_LEVEL=debugstill produces HTTP debug output🤖 Generated with Claude Code