log rate limiting: reformat limiter messages, and use nonempty burst size.

- Reformat the warning about a message being rate limited to print the
  format string, rather than the formatted message. This helps give a
  clue what "type" of message is being limited.

- Change the rate limit warning to be [RATE LIMITED] in all caps. This
  uses less space on each line, plus is more noticeable.

- In tailscaled, change the frequency to be less often (once every 5
  seconds per format string) but to allow bursts of up to 5 messages.
  This greatly reduces the number of messages that are rate limited
  during startup, but allows us to tighten the limit even further during
  normal runtime.

Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
This commit is contained in:
Avery Pennarun
2020-05-20 11:49:35 -04:00
parent f2db4ac277
commit af9328c1b7
3 changed files with 11 additions and 9 deletions

View File

@@ -60,7 +60,7 @@ func main() {
socketpath := getopt.StringLong("socket", 's', paths.DefaultTailscaledSocket(), "Path of the service unix socket")
logf := wgengine.RusagePrefixLog(log.Printf)
logf = logger.RateLimitedFn(logf, 1*time.Second, 1, 100)
logf = logger.RateLimitedFn(logf, 5*time.Second, 5, 100)
err := fixconsole.FixConsoleIfNeeded()
if err != nil {