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

Prevent logger recursion during startup #1158

Merged
merged 1 commit into from
Aug 31, 2020
Merged

Conversation

delner
Copy link
Contributor

@delner delner commented Aug 27, 2020

When Components are built, they sometimes log messages to Datadog.logger. If this happens, logger is not yet built/resolved, so it will lazily build another, triggering yet another log message and forming a recursive loop.

A simple way around this is to have some kind of default logger when components have not been initialized, but yields to the configured logger once its been built/configured.

@delner delner added bug Involves a bug core Involves Datadog core libraries labels Aug 27, 2020
@delner delner requested review from marcotc, ericmustin and a team August 27, 2020 17:21
@delner delner self-assigned this Aug 27, 2020
@delner
Copy link
Contributor Author

delner commented Aug 27, 2020

This bug manifested while building my profiling autostart feature because at the end of the components build process, the profiler would be started which would trigger a log message, which would get the logger (which was not yet set), which would trigger another component build, resulting in the loop.

Maybe another way to work around this is to start components after its been set on the @components variable. This would sidestep the log messages in the startup phase, but would not address log messages in the initialization phase.

Copy link
Member

@marcotc marcotc left a comment

Choose a reason for hiding this comment

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

Is there a practical way to test this change?

@delner
Copy link
Contributor Author

delner commented Aug 27, 2020

Maybe you could test to see if the default logger gets replaced by the logger from the components? Otherwise all this does is prevent a stack overflow, but I'm not sure if there's a practical test for that.

Copy link
Member

@marcotc marcotc left a comment

Choose a reason for hiding this comment

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

I think we should protection around removing this block in the future, we can currently do that without any impact on CI.

@delner delner merged commit e98ca74 into master Aug 31, 2020
@delner delner deleted the fix/logger_recursion branch August 31, 2020 20:13
@delner delner mentioned this pull request Aug 31, 2020
@marcotc marcotc added this to the 0.40.0 milestone Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug core Involves Datadog core libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants