Skip to content

[log] feat(httputil): add debug logging to HTTP utility functions#4324

Merged
lpcox merged 2 commits intomainfrom
log/httputil-debug-logging-5d22641751563e13
Apr 22, 2026
Merged

[log] feat(httputil): add debug logging to HTTP utility functions#4324
lpcox merged 2 commits intomainfrom
log/httputil-debug-logging-5d22641751563e13

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Add a logHTTP debug logger (httputil:httputil) and meaningful logging calls to the three utility functions in internal/httputil/httputil.go.

Changes

File modified: internal/httputil/httputil.go (1 file, focused PR)

Logger added

var logHTTP = logger.New("httputil:httputil")

Logging calls added

Function What's logged
WriteJSONResponse Status code, serialised body size, and marshal errors
ParseRateLimitResetHeader Parsed reset timestamp (RFC 3339) or parse failure
IsTransientHTTPError Status code when a transient error is detected

Why this is useful

These helpers are called across the server and proxy packages. Having debug output here makes it straightforward to trace:

  • Which status codes are being written to clients
  • Whether X-RateLimit-Reset headers are being parsed correctly (relevant to the circuit-breaker reset logic)
  • When the gateway decides a backend response is transient and eligible for retry

Enable with:

DEBUG=httputil:* ./awmg --config config.toml

Validation

  • go build ./...
  • go vet ./internal/httputil/...
  • go test ./internal/httputil/...

Generated by Go Logger Enhancement · ● 2M ·

Add a logger (httputil:httputil) and debug logging calls to the three
utility functions in internal/httputil/httputil.go:

- WriteJSONResponse: log status code, body size, and marshal errors
- ParseRateLimitResetHeader: log parsed reset time or parse failures
- IsTransientHTTPError: log when a transient error code is detected

These helpers are called widely across the server and proxy packages,
so debug logging here makes it easier to trace HTTP response behaviour
and rate-limit handling during troubleshooting.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation enhancement New feature or request labels Apr 22, 2026
@lpcox lpcox marked this pull request as ready for review April 22, 2026 14:34
Copilot AI review requested due to automatic review settings April 22, 2026 14:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated debug logger to internal/httputil and instruments the shared HTTP helper functions to emit useful debug traces when DEBUG=httputil:* (or similar) is enabled.

Changes:

  • Introduces logHTTP (httputil:httputil) as the package debug logger.
  • Adds debug logs to WriteJSONResponse, ParseRateLimitResetHeader, and IsTransientHTTPError to surface status codes, parse results, and marshal failures.
Show a summary per file
File Description
internal/httputil/httputil.go Adds a logger.New(...) debug logger and emits debug logs from the three core httputil helpers.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread internal/httputil/httputil.go Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit 80ecf22 into main Apr 22, 2026
14 checks passed
@lpcox lpcox deleted the log/httputil-debug-logging-5d22641751563e13 branch April 22, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants