feat(kafka-logger): add max req/resp body size attributes#11133
Merged
moonming merged 8 commits intoApr 16, 2024
Merged
Conversation
shreemaan-abhishek
marked this pull request as ready for review
April 10, 2024 01:10
starsz
reviewed
Apr 10, 2024
| local math = math | ||
| local pairs = pairs | ||
| local type = type | ||
| local req_body = ngx.req.read_body |
Contributor
There was a problem hiding this comment.
Suggested change
| local req_body = ngx.req.read_body | |
| local req_read_body = ngx.req.read_body |
| ctx._body_buffer[ctx._plugin_name] = nil | ||
| return body_buffer | ||
| if max_resp_body_bytes and #body_data >= max_resp_body_bytes then | ||
| body_data = str_sub(body_data, 1, max_resp_body_bytes) |
Contributor
There was a problem hiding this comment.
Why do we need to sub the body_data again here?
Contributor
Author
There was a problem hiding this comment.
in 213, we just sub the chunk this happens in the case when this is the first and last chunk of body_filter phase. (since eof == true and body_buffer is nil).
in 221 we need to sub because it is the last chunk but not the very first one.
Contributor
There was a problem hiding this comment.
I think if it's the first chunk, it will be dealed in line ~202
Contributor
Author
There was a problem hiding this comment.
hmm now it makes sense but I think we are calling sub on 213 on chunk because body_buffer is nil. And on 221 we are calling it on body data formed after concat_tab the body_buffer table.
starsz
approved these changes
Apr 15, 2024
moonming
approved these changes
Apr 15, 2024
4 tasks
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In cases where the req/response body is very large and when include_req_body/resp_body is enabled this leads to very high CPU usage and can even cause unavailability. To fix such event, two new attributes are introduced:
Checklist