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

flow.log: Rate-limit individual messages, possibly via macro magic. #70

Open
ygoldfeld opened this issue Mar 10, 2024 · 0 comments
Open
Labels
enhancement New feature or request from-akamai-pre-open Issue origin is Akamai, before opening source

Comments

@ygoldfeld
Copy link
Contributor

Filed by @ygoldfeld pre-open-source:

The specific feature involves a coder, at a given log call site, specifying that that message should be rate-limited in a certain way. Internally some macro stuff happens that basically counts how much it has been logged lately (invisibly to coder) and doesn't log it beyond a certain point. It would probably log something like <...message logged 7,443 more times...>.

We have some code elsewhere, with notes in a related ticket at Akamai, that can be used as conceptual inspiration. Maybe we can do it more prettily than that, but from what I recall it was pretty clever actually.

According to certain devs and architect:

"did not require changes to it for 10+ years."

"the general idea is, that these macros add a number of static variables that do the rate limit calculation. It has only one downside: inside of a C++ block {} only a single of such rate limit macros can be used."

"The clever implementation detail of the is that the rate limit calculation happens before the printf() style log function is evaluated. If the rate limit says that the log should not be printed, then the printf() stuff doesn't happen and thus CPU cycles are not wasted."

@ygoldfeld ygoldfeld added enhancement New feature or request from-akamai-pre-open Issue origin is Akamai, before opening source labels Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request from-akamai-pre-open Issue origin is Akamai, before opening source
Projects
None yet
Development

No branches or pull requests

1 participant