fix(opentelemetry-instrumentation-logging): Ensure that logging is pr…#2384
Open
dhofstetter wants to merge 2 commits intoopen-telemetry:mainfrom
Open
fix(opentelemetry-instrumentation-logging): Ensure that logging is pr…#2384dhofstetter wants to merge 2 commits intoopen-telemetry:mainfrom
dhofstetter wants to merge 2 commits intoopen-telemetry:mainfrom
Conversation
Contributor
|
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
xrmx
reviewed
Apr 29, 2024
40d5db1 to
fb3ceab
Compare
xrmx
reviewed
Apr 30, 2024
Closed
7 tasks
fb3ceab to
0854421
Compare
Contributor
Author
|
Changed according to suggestions and rebased to main |
ilkerhat
approved these changes
Jun 6, 2024
…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
Contributor
Author
|
Rebased again to main. @ocelotl Would you have your final look onto this pr? |
pmcollins
reviewed
Jun 21, 2024
instrumentation/opentelemetry-instrumentation-logging/tests/test_logging.py
Show resolved
Hide resolved
lzchen
reviewed
Jul 8, 2024
| if root_logger.hasHandlers(): | ||
| root_logger.setLevel(level) | ||
| for handler in root_logger.handlers: | ||
| handler.setFormatter(logging.Formatter(format)) |
Contributor
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 |
Member
|
Same here, I'm willing to help out on this issue & potential fix. |
MikeGoldsmith
added a commit
to honeycombio/opentelemetry-python-contrib
that referenced
this pull request
Feb 13, 2026
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
10 tasks
Member
|
Opened the following PR as this has been stale for 18 months: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.