-
Notifications
You must be signed in to change notification settings - Fork 457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for long log lines #265
Conversation
@tomhjp Excuse me, Can you help me check this pr? Do you have any suggestions? |
Hey @luoxiaohei - my plate is pretty full atm, but just wanted to say this looks like something we should be able to land and I'll try to revisit it soon. Thanks for putting this together, I can see it's been very thoughtfully constructed. |
Thanks for your positive feedback on my pr, I look forward to seeing it merged soon. |
Thinking out loud a bit, an alternative solution would be to allow lines that cross the buffer threshold to build up in memory and deserialise them once Instead, this PR allows clients to opt into behaviour that increases memory consumption, and still keeps a hard cap on it at the increased level. It's more fiddly because now clients have to be aware of the maximum log size they expect from a plugin, but also safer so I think the correct decision. Does that reasoning track with you @luoxiaohei, or am I missing an opportunity to simplify here? |
@tomhjp Yes, your reasoning tracks with me. I think the configurable option is a good balance between flexibility and safety. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I just re-read the PR description and saw you already discussed my previous question 🤦♂️
Looks good, but one naming nit and I'd like to make sure we very explicitly cover the intent of the change in unit tests.
…ing test - Renamed `LogBufferSize` to `PluginLogBufferSize` to better reflect its purpose. - Updated all references of `LogBufferSize` to `PluginLogBufferSize`. - Added a new test `TestClient_logStderrParseJSON` to verify the parsing of JSON formatted logs.
@tomhjp I've refining the naming and enhancing the unit tests to explicitly cover the intent of the changes. Please take another look when you have a moment. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sec32fun32
- Add `PluginLogBufferSize` option to ClientConfig, defaulting to previous 64KiB size - Added a new test `TestClient_logStderrParseJSON` to verify the parsing of JSON formatted logs.
This pull request introduces a new feature to the
ClientConfig
in theclient.go
. The main change involves the addition of aLogBufferSize
field, which will serve as the buffer size for reading stderr logs.Currently, the
stdErrBufferSize
is set to a default value of 64 KB. When a log line exceeds this size, the client will not perform json unmarshal and subsequent processing for that line. This behavior can be unfriendly for certain use cases that involve lengthy logs.To address this limitation, the proposed solution is to add the
LogBufferSize
field to theClientConfig
, allowing users to customize their own buffer size when creating a client. If the user doesn't specify a value, the default of 64 KB will be used to maintain compatibility with the current implementation.An alternative approach would be to handle oversized logs by creating a new buffer to retain truncated data, concatenating it with historical data on the next read, and then proceeding with the complete log unmarshal. However, this method introduces added complexity and could lead to performance overhead in scenarios where logs consistently exceed the buffer size.
Considering simplicity and ease of implementation, the configuration-based solution is preferred. Users can now effortlessly fine-tune the buffer size to suit their specific logging needs.