fix(opentelemetry-instrumentation-logging): Ensure that logging is pr…#2384
fix(opentelemetry-instrumentation-logging): Ensure that logging is pr…#2384dhofstetter wants to merge 2 commits intoopen-telemetry:mainfrom
Conversation
|
Nice @dhofstetter. Thanks for taking this on. Looks like my pr #1939 is fully implemented here. I can close #1939 when this is done. |
5ebe8c8 to
02f5edb
Compare
3e45d57 to
c7264c1
Compare
40d5db1 to
fb3ceab
Compare
fb3ceab to
0854421
Compare
|
Changed according to suggestions and rebased to main |
…operly configured independently of the order of instrumentation (this helps especially in case of autoinstrumentation) - add method to perform proper logging initialisation - add unittests - extend CHANGELOG
0854421 to
51ccb36
Compare
|
Rebased again to main. @ocelotl Would you have your final look onto this pr? |
instrumentation/opentelemetry-instrumentation-logging/tests/test_logging.py
Show resolved
Hide resolved
| if root_logger.hasHandlers(): | ||
| root_logger.setLevel(level) | ||
| for handler in root_logger.handlers: | ||
| handler.setFormatter(logging.Formatter(format)) |
There was a problem hiding this comment.
Shouldn't we be only reconfiguring the format for the OpenTelemetry LoggingHandler and not all of the user's handlers?
|
Hey @dhofstetter, this fix could greatly help us! What's the status of it? I'd be glad to help if needed |
|
Same here, I'm willing to help out on this issue & potential fix. |
basicConfig() no-op when handlers exist (autoinstrumentation, Gunicorn, Flask). Fix: update existing handlers instead of only calling basicConfig. Saves/restores state for clean uninstrumentation. Supersedes open-telemetry#2384, fixes open-telemetry#2346
|
Opened the following PR as this has been stale for 18 months: |
|
This should be closed in favour of the following PR: |
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
|
We moved the code to the logging instrumentation so the changes should be done there. |
…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.