fix(opentelemetry-instrumentation-logging): Ensure that logging is pr… #2384
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
…operly configured independently of the order of instrumentation (this helps especially in case of autoinstrumentation)
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
I have changed the logging instrumentation in a way that ensures proper log setup no matter if the application (log) was already configured.
The changes are in a way s.t. we check before applying log level and format to check if basicConfig should be used. Otherwise we are going to modify the log level and handlers "manually".
I also changed the uninstrument method (which is mainly for the
test_uninstrumentedtest. Because as soon as we changed the log format and we "uninstrument" the application, then the logs cannot be formatted anymore.The changes are highly inspired by this open pull request. So props, to figure out a neat way to resolve this issue go to @rjduffner.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
I have written unit tests to prove that everything should work as expected.
To verify this with some application, you can locally install the repo and perform auto-instrumentation of an application. There it can be verified that the issues mentioned above are gone.
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.