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

Add ioutil.Discard to logger to prevent leaks #74

Closed

Conversation

mlehner616
Copy link
Contributor

Related to #71. The documentation in https://github.com/kdar/logrus-cloudwatchlogs alludes (albeit vaguely) to the fact that ioutil.Discard is required to release memory and may actually be related to this issue in logrus upstream, sirupsen/logrus#328.

This likely has the side-effect of disabling logging to stdout so I'm not sure this is desirable.

@itsdalmo
Copy link
Contributor

itsdalmo commented Mar 2, 2019

Not sure I follow this one, but you say it fixed #71 in your experience?

The documentation in https://github.com/kdar/logrus-cloudwatchlogs alludes (albeit vaguely) to the fact that ioutil.Discard is required to release memory

Do you have a link to the documentation which mentions this?

and may actually be related to this issue in logrus upstream, sirupsen/logrus#328.

This issue seems to be a "non issue", it's just a question about how to disable logging to stdout?

Overall, if adding ioutil.Discard solves the CPU issue, I feel like we are working around a bug that needs to be fixed (or at least) reported in CloudWatch hook, or more likely Logrus itself. Also, I don't think we should disable logging to stdout, or at least it should be a separate flag.

edit: Just had a look at the kdar/logrus-cloudwatchlogs code, and when using NewHook() as we are doing, the code for the hook seems fairly simple (more complex if we had used a batching hook) and solid - I couldn't see anything at a glance that would cause problems with CPU usage. I've also looked through the aws-sdk-go CHANGELOG.md to see if there has been any issues with cloudwatchlogs and CPU, but couldn't find anything related. I also could not find any issues regarding CPU for Logrus itself either, so if using ioutil.Discard indeed fixes the issue for you we should be looking at our own code and Logrus' hook implementation (and/or submit an issue).

@mlehner616
Copy link
Contributor Author

I confirmed this had no impact on the CPU usage and the SpotListener patches #72 and #73 fixed the leak issues. Closing. Thank you for the quick responses and attention!

@mlehner616 mlehner616 closed this Mar 9, 2019
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.

3 participants