Skip to content

Add http debugging roundtripper - #985

Open
jaymzh wants to merge 1 commit into
prometheus:mainfrom
jaymzh:http-debug
Open

jaymzh wants to merge 1 commit into
prometheus:mainfrom
jaymzh:http-debug

Conversation

@jaymzh

@jaymzh jaymzh commented Sep 3, 2026

Copy link
Copy Markdown

When developing things (like #962), it's useful to be able
to debug the http roundtrips. This adds debugRoundTripper that other prom
tools can use (behind a --http.debug flag) which automatically
logs the HTTP requests while redacting credentials.

Implemented downstream usage for promtool and amtool: prometheus/prometheus#19577 and prometheus/alertmanager#5541

Signed-off-by: Phil Dibowitz phil@ipom.com

@jaymzh jaymzh changed the title Add http debugging Add http debugging roundtripper Sep 3, 2026
When developing things (like prometheus#962), it's useful to be able
to debug the http roundtrips. This adds `debugRoundTripper` that other prom
tools can use (behind a `--http.debug` flag) which automatically
logs the HTTP requests while redacting credentials.

Signed-off-by: Phil Dibowitz <phil@ipom.com>
jaymzh added a commit to jaymzh/alertmanager that referenced this pull request Sep 3, 2026
This depends on prometheus/common#985 for the
infrastructure, but adds an --http.debug flag that uses the
prometheus/common debug roundtripper to provide debug logs with
credentials censored.

Signed-off-by: Phil Dibowitz <phil@ipom.com>
@bboreham

bboreham commented Sep 8, 2026

Copy link
Copy Markdown
Member

Why would this live in a Prometheus package? Seems quite general.

What similar existing tools are out there?

@jaymzh

jaymzh commented Sep 17, 2026

Copy link
Copy Markdown
Author

There's not a decent equivalent I can find. There's replacements for the entire HTTP client that have similar things, but it seems extreme to rip out the entire http client.

The closest thing I've found is net/http/httputil's httputil.DumpRequestOut and DumpResponse. However, it has no redaction or body-size limit. Further, DumpResponse(..., true) buffers the entire body, so we would still need a wrapper for safe previews.

Adding a simple round-tripper to do this didn't seem like a huge problem, and I implemented not for fun, but because I needed something like it to implement #962

@jaymzh

jaymzh commented Sep 17, 2026

Copy link
Copy Markdown
Author

(that said, if this isn't desired, I have no hard need for it now that #962 is written... the cfaccess support was the goal, and that's the PR I'm most interested in getting merged. I just thought it'd be a good-citizen thing to do to make this generic and upstream it as well)

@jaymzh

jaymzh commented Sep 17, 2026

Copy link
Copy Markdown
Author

(which is my subtle attempt to get attention on #962 ;) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants