internal/appsec/emitter/waf: reduce rate limiting log spam
What does this PR do?
WIP: my first approach (add a "limited" field to the operation) was wrong since the rate limiter is a global thing and each benchmark iteration is a new "operation"
The ContextOperation.AddEvent method logs a warning if the ContextOperation's rate limit is hit. If there are a burst of calls to AddEvent, this means there will be a corresponding burst of logs. This happens for example when running BenchmarkGraphQL on the benchmarking platform. Only the first log is really useful.
Motivation
Not sure how much it affects users. But I think it's making our microbenchmark runs slow? That's where I noticed the log spam. Example pipeline
Benchmarks
Benchmark execution time: 2024-09-25 15:15:24
Comparing candidate commit c6dfc42f3b637ba10acdc1e1568386d90a3fc246 in PR branch nick.ripley/reduce-waf-rate-limit-logs with baseline commit 7699f9e40040f4eafb5395a5532dd1134dbd0bd0 in branch main.
Found 1 performance improvements and 0 performance regressions! Performance is the same for 58 metrics, 0 unstable metrics.
scenario:BenchmarkInjectW3C-24
- 🟩
execution_time[-178.231ns; -146.569ns] or [-4.272%; -3.513%]