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

chore(kuma-cp) disable log sampling #2273

Merged
merged 1 commit into from
Jul 2, 2021

Conversation

jakubdyszkiewicz
Copy link
Contributor

Summary

While stress testing KDS I noticed that some logs about creating resources are missing.
After more investigation, it turned out that even with a simple loop

for i := 0; i < 200; i++ {
  core.Log.Info("test", "x", i)
}

we are dropping logs after 100.

It's because we have log sampling enabled.

Why sample application logs?
Applications often experience runs of errors, either because of a bug or because of a misbehaving user. Logging errors is usually a good idea, but it can easily make this bad situation worse: not only is your application coping with a flood of errors, it's also spending extra CPU cycles and I/O logging those errors. Since writes are typically serialized, logging limits throughput when you need it most.

Sampling fixes this problem by dropping repetitive log entries. Under normal conditions, your application writes out every entry. When similar entries are logged hundreds or thousands of times each second, though, zap begins dropping duplicates to preserve throughput.

https://github.com/uber-go/zap/blob/master/FAQ.md#why-sample-application-logs

While I understand the rationale, I don't think it's the right solution - at least for Kuma and INFO logs. Maybe it's fine for errors with the same msg and key-value pairs, but I'd do this only if we have such a problem. Overall, It only makes debugging even more confusing.

If we have a loop that spams logs, we should introduce backoff, not drop logs.

Documentation

  • No docs

Testing

  • Unit tests
  • E2E tests
  • Manual testing on Universal
  • Manual testing on Kubernetes

Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
Copy link
Contributor

@bartsmykla bartsmykla left a comment

Choose a reason for hiding this comment

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

lgtm

@jakubdyszkiewicz jakubdyszkiewicz merged commit cc0cb70 into master Jul 2, 2021
@jakubdyszkiewicz jakubdyszkiewicz deleted the chore/disable-log-sampling branch July 2, 2021 12:45
mergify bot pushed a commit that referenced this pull request Jul 2, 2021
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
(cherry picked from commit cc0cb70)
jakubdyszkiewicz pushed a commit that referenced this pull request Jul 5, 2021
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
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

2 participants