Skip to content
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

refactor: avoid evaluating Data more than once in SLOG_THROTTE macro #12927

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

SergeTupchiy
Copy link
Contributor

@SergeTupchiy SergeTupchiy commented Apr 24, 2024

Release version: v/e5.7.0

Summary

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:

  • Added tests for the changes
  • Added property-based tests for code which performs user input validation
  • Changed lines covered in coverage report
  • Change log has been added to changes/(ce|ee)/(feat|perf|fix|breaking)-<PR-id>.en.md files
  • For internal contributor: there is a jira ticket to track this change
  • Created PR to emqx-docs if documentation update is required, or link to a follow-up jira ticket
  • Schema changes are backward compatible

Checklist for CI (.github/workflows) changes

  • If changed package build workflow, pass this action (manual trigger)
  • Change log has been added to changes/ dir for user-facing artifacts update

@SergeTupchiy SergeTupchiy requested review from lafirest and a team as code owners April 24, 2024 13:03
false ->
ok
end
end)()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may do not call (fun() -> ... end)() before the check, e.g.:

-define(SLOG_THROTTLE(Level, Data, Meta),
    case logger:allow(Level, ?MODULE) of
        true ->
            (fun(#{msg := __Msg} = __Data) ->
                case emqx_log_throttler:allow(__Msg) of
                    true ->
                        logger:log(Level, __Data, Meta);
                    false ->
                        ?_DO_TRACE(Level, __Msg, maps:merge(__Data, Meta))
                end
            end)(Data);
        false ->
            ok
    end
).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍 , fixed

savonarola
savonarola previously approved these changes Apr 24, 2024
@SergeTupchiy SergeTupchiy merged commit 7fb309c into emqx:master Apr 24, 2024
173 checks passed
@yanzhiemq
Copy link
Collaborator

TestExecution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants