-
Notifications
You must be signed in to change notification settings - Fork 641
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
LoggingInstrumentation: Set Handler Format Explictly If basicConfig Has Already Been Called #1939
Conversation
59f8d0b
to
68687f2
Compare
root_logger = logging.getLogger() | ||
if root_logger.hasHandlers(): | ||
for handler in root_logger.handlers: | ||
handler.setFormatter(logging.Formatter(log_format)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about log_level
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
going to close this pr. @dhofstetter has a more complete implementation. thanks @dhofstetter and @ocelotl |
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.