Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe changes implement body capture functionality for streaming proxies by introducing a Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Handler as Proxy Handler
participant TeeReader
participant LimitedWriter
participant Buffer as Response Buffer
participant Upstream
participant Session
Client->>Handler: HTTP Request (streaming)
Handler->>Upstream: Forward request
Upstream-->>Handler: Response stream
Handler->>TeeReader: Wrap response body
TeeReader->>Handler: Stream bytes to client
TeeReader->>LimitedWriter: Tee bytes for capture
LimitedWriter->>Buffer: Write (up to 1 MiB limit)
Buffer-->>LimitedWriter: Confirm write
LimitedWriter-->>TeeReader: Continue passthrough
Handler->>Session: SetResponseBody(captured bytes)
Handler-->>Client: Complete response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
24214fd to
b7a6a02
Compare
adf10b1 to
95239d2
Compare
b7a6a02 to
48a45ff
Compare
48a45ff to
84d845e
Compare
95239d2 to
cc4c976
Compare
cc4c976 to
deeb119
Compare
84d845e to
b017f28
Compare
b017f28 to
1b7941a
Compare
1b7941a to
829c80d
Compare
786e201 to
2c8fd2b
Compare
|
hmmm, I'm not sure if we want this tbh. We still need to find a good way to let the user configure logging and especially masking and streaming can produce really really large bodies, which we probably don't want in clickhouse what was the motivation here? the PR description is shit |
That we can actually support streaming, otherwise zen / the logging tries to read the fully body and locks up til the end of response Which buffers the whole stream and we only return it once the stream gets closed |
0099993 to
f565e5c
Compare
2c8fd2b to
7682b11
Compare
7682b11 to
5d3b32e
Compare
f565e5c to
a3139bc
Compare
Merge activity
|
5d3b32e to
5070c7f
Compare
a3139bc to
5c2ca7c
Compare
5070c7f to
d99dc35
Compare

What does this PR do?
Adds streaming request/response body capture for logging in the proxy handlers.
Previously, streaming requests (gRPC, Connect) had their bodies skipped entirely to avoid buffering issues. This change uses
TeeReaderwith aLimitedWriterto capture up to 1 MiB of streaming body content for logging purposes while allowing the stream to flow through uninterrupted.The implementation includes:
LimitedWriterthat caps captured bytes at a configurable limit (1 MiB) and silently discards excess dataTeeReaderfor streaming body captureSetResponseBodymethod onSessionto allow proxy handlers to feed captured response bodies back for middleware loggingIsStreamingContentTypefunction for reuse across servicesFixes # (issue)
Type of change
How should this be tested?
TestLimitedWriter_*tests to verify the limited writer behaviorTestHandler_StreamingBodyCapturetest to verify streaming request/response body captureTestHandler_ServerStreamBodyCapturetest to verify server-only streaming scenariosTestHandler_StreamingBodyCapture_RespectsLimittest to verify the 1 MiB capture limit is enforcedChecklist
Required
pnpm buildpnpm fmtmake fmton/godirectoryconsole.logsgit pull origin mainAppreciated