Skip to content
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

fix: send StructuredLogHandler instrumentation log using an explicit logger #705

Merged
merged 7 commits into from
Jan 18, 2023

Conversation

daniel-sanche
Copy link
Contributor

Fixes #704

The StructuredLogHandler sends an instrumentation log in the following format:

logging.info(diagnostic_object.payload)

This uses the root logging instance, which may not contain a GCP Logging Handler, so the log may not make its way to GCP.

This PR addresses this by obtaining a fresh logger instance, connecting the active StructuredLogHandler object as a handler, and emitting the instrumentation that way. using this method, the instrumentation log will be reliably printed to stdout in the same format as the other logs

@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. api: logging Issues related to the googleapis/python-logging API. labels Jan 14, 2023
@daniel-sanche daniel-sanche marked this pull request as ready for review January 17, 2023 22:17
@daniel-sanche daniel-sanche requested review from a team as code owners January 17, 2023 22:17
@losalex losalex self-assigned this Jan 17, 2023
Copy link
Contributor

@losalex losalex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - thanks for fixing this!

@daniel-sanche daniel-sanche added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 18, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 18, 2023
@daniel-sanche daniel-sanche merged commit ac6a2c6 into main Jan 18, 2023
@daniel-sanche daniel-sanche deleted the structured_log_instrumentation_fix branch January 18, 2023 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/python-logging API. size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: StructuredLogHandler instrumentation is not reliable
3 participants