Skip to content

proxy: make body capture size configurable, with opt-in full capture per host #63

Description

@dpup

Problem

proxy/proxy.go:150 fixes the capture at const MaxBodySize = 8 * 1024, used by captureBody (proxy/proxy.go:374) for both directions. There is no way to raise it, for a host or at all.

Where it bit

Debugging a gateway that stalled on specific requests. The failing payloads were ~264 KB; the log held the first 8 KB, which was the conversation preamble — identical across every request in the session and therefore useless for telling the failing request from a succeeding one.

Concretely, that cost:

  • A wrong conclusion. I hashed the captured bodies to argue three failures were "the identical request retried". They shared only the truncated prefix; Content-Length showed two distinct bodies. The truncation silently made different requests look identical.
  • Unreproducible failure. Nine probes reconstructing the request from its shape — size, message count, tools, cache breakpoints, beta headers, and the real 8 KB prefix — all succeeded. The trigger lived past byte 8192, so the only complete copy of the failing request was on the vendor's servers.

Suggestion

Make the cap configurable, and allow opt-in full capture scoped to a host, e.g. SetBodyCaptureLimit(host string, n int) with the current 8 KB as the default for everything else.

Scoping matters: full capture is expensive in memory and disk (captureBody currently streams the remainder rather than buffering it, which should be preserved for unscoped hosts), and bodies may hold sensitive content — so this should be something a user turns on deliberately for one host while debugging, not a global switch.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions