-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Capture python warnings as logs #5730
Conversation
@@ -50,6 +50,8 @@ | |||
|
|||
monkey_patch_pyyaml() | |||
|
|||
# Let's capture warnings as logs so it's easier for log parser to handle them. | |||
logging.captureWarnings(True) |
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.
Mind if we put this in the log module's init_logging
?
Don't think option 2 really makes sense |
@hithwen why is that ? Isn't Python
|
We need to be in control of what appears in our UI |
That's a good point ! 👍 |
Codecov Report
|
822987e
to
39a48ce
Compare
What does this PR do?
Option 1: Capture python warnings as logs (SELECTED)
Just use
logging.captureWarnings(True)
Option 2: Capture python warning as
AgentCheck.warning()
, so that they are visible in Datadog UI.Would require patching warning similar to what logging does: https://github.com/python/cpython/blob/master/Lib/logging/__init__.py#L2175-L2207
This is more in line with:
Motivation
Python warnings are printed to stdout which make then hard to parse for logs integration.
Additional Notes
Review checklist (to be filled by reviewers)
changelog/
andintegration/
labels attached