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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: don't be kill when send large payload when log is debug #11279
Conversation
format_payload(Payload, hex) when ?MAX_PAYLOAD_FORMAT_LIMIT(Payload) -> | ||
["Payload(hex)=", binary:encode_hex(Payload)]; | ||
format_payload(_, hidden) -> | ||
"Payload=******"; |
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.
Or only display a part to keep consistent with the above
apps/emqx/src/emqx_packet.erl
Outdated
format_payload(_, hidden) -> | ||
"Payload=******"; | ||
format_payload(Payload, _) -> | ||
["Payload=Large data detected (", integer_to_list(byte_size(Payload)), " bytes)"]. |
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.
Agree with @lafirest, perhaps it's better to display ?MAX_PAYLOAD_FORMAT_SIZE
characters in this case
e9475c0
to
5a4dd3a
Compare
@@ -679,4 +679,7 @@ end). | |||
-define(THROW_FRAME_ERROR(Reason), erlang:throw({?FRAME_PARSE_ERROR, Reason})). | |||
-define(THROW_SERIALIZE_ERROR(Reason), erlang:throw({?FRAME_SERIALIZE_ERROR, Reason})). | |||
|
|||
-define(MAX_PAYLOAD_FORMAT_SIZE, 1024). | |||
-define(MAX_PAYLOAD_FORMAT_LIMIT(Bin), (byte_size(Bin) =< ?MAX_PAYLOAD_FORMAT_SIZE)). |
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.
nit: UNDER_MAX....
format_payload(Payload, hex) when ?MAX_PAYLOAD_FORMAT_LIMIT(Payload) -> binary:encode_hex(Payload); | ||
format_payload(<<Part:100, _/binary>> = Payload, _) -> | ||
[ | ||
Part, |
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.
Format Part
according to 2nd arg.
format_payload(<<Part:100, _/binary>> = Payload, _) -> | ||
[ | ||
"Payload=", | ||
Part, |
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.
format Part
according to 2nd arg.
Fixes https://emqx.atlassian.net/browse/EMQX-10482
Summary
馃 Generated by Copilot at b277d4a
This pull request improves the performance and readability of the
emqx_packet
andemqx_trace_formatter
modules by using OTP 24 features and refactoring some code. It also fixes some test settings and limits the output of large payloads in the trace and packet formatting functions.PR Checklist
Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:
changes/(ce|ee)/(feat|perf|fix)-<PR-id>.en.md
filesChecklist for CI (.github/workflows) changes
changes/
dir for user-facing artifacts update