You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 23, 2023. It is now read-only.
I think we should make a few more improvements here, though they are slightly out of scope.
both the logging and tracing middleware are capturing the responseBody if the request status >= 400. we dont need two copies of the body.
I really think we should set a cap on the number of bytes to capture. if the something goes wrong and a really large response is written we are going to cause problems for our logging and tracing platforms if we try and write 100's of KB or larger.
to address these i suggest
merge the tracing and logging middleware into one, or use a shared responseWriter wrapper.
for a shared responseWriter you can just check if current responseWriter is already a 'CaptureErrorResponseWriter' or not to see if you need to updated it. eg
var wrappedRW *CaptureErrorResponseWriter
if wrappedRW, ok := ctx.Resp.(*CaptureErrorResponseWriter); !ok {
wrappedRW = &CaptureErrorResponseWriter{ResponseWriter: ctx.Resp
}
....
errBody := wrappedRW.ErrorBody()
only put up to 1k of data into the captured errBody, and then additionally if we need to decompress it, only return the first 1k of data after decompression. this will work fine with gzip. It will decompress what it can then return an error. So if you get decoded data back, just ignore the error.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I think we should make a few more improvements here, though they are slightly out of scope.
to address these i suggest
for a shared responseWriter you can just check if current responseWriter is already a 'CaptureErrorResponseWriter' or not to see if you need to updated it. eg
Originally posted by @woodsaj in #1693 (comment)
The text was updated successfully, but these errors were encountered: