LoggingInstrumentation: Set Handler Format Explictly If basicConfig Has Already Been Called#1939
Closed
rjduffner wants to merge 3 commits intoopen-telemetry:mainfrom
Closed
LoggingInstrumentation: Set Handler Format Explictly If basicConfig Has Already Been Called#1939rjduffner wants to merge 3 commits intoopen-telemetry:mainfrom
rjduffner wants to merge 3 commits intoopen-telemetry:mainfrom
Conversation
59f8d0b to
68687f2
Compare
Contributor
7 tasks
ocelotl
reviewed
May 1, 2024
| root_logger = logging.getLogger() | ||
| if root_logger.hasHandlers(): | ||
| for handler in root_logger.handlers: | ||
| handler.setFormatter(logging.Formatter(log_format)) |
Contributor
Contributor
Author
There was a problem hiding this comment.
@ocelotl, as @dhofstetter, said lets go with their newer and more complete pr. i meant this as more a discussion starter.
thanks for the review though.
also ill close this pr so its not confusing anymore
Contributor
Author
|
going to close this pr. @dhofstetter has a more complete implementation. thanks @dhofstetter and @ocelotl |
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.
Description
We are using open telemetry with Gunicorn. Due to the forking model of Gunicorn (https://opentelemetry-python.readthedocs.io/en/latest/examples/fork-process-model/README.html), we are unable to do automatic instrumentation.
Since Gunicorn sets up logging very early, setting the logFormat via OTEL_PYTHON_LOG_CORRELATION and OTEL_PYTHON_LOG_FORMAT doesn't do anything. This causes us to have to set the log format to include the trace_id/span_id in the generic formatter. This means that the LoggingInstrumention always has to be instrumented even locally.
This is a first draft of a potential way to fix it. I am looking for some feedback.
The Fix:
The Open Questions:
The Annoying:
Type of change
How Has This Been Tested?
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.