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

feat: allow modifying LogEntry data using extra argument #129

Merged
merged 37 commits into from Jan 9, 2021

Conversation

daniel-sanche
Copy link
Contributor

@daniel-sanche daniel-sanche commented Dec 11, 2020

Our library allows users to use the standard Python logging library to send logs to Stackdriver. So far, this method has had limitations, because users couldn't customize any log data associated with the message. This PR allows users to send in metadata fields using the standard extra dictionary parameter, allowing users to override fields like trace, span_id, http_request, and labels.

logging.info('log test', extra={'trace':'12345''})

So far, this change will only work on AppEngine and the using the base CloudLoggingHandler, but I'll slowly roll out support to more environments over time

Fixes #110 and lays the groundwork for later changes

@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/python-logging API. label Dec 11, 2020
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Dec 11, 2020
@daniel-sanche daniel-sanche marked this pull request as ready for review December 16, 2020 23:21
@daniel-sanche daniel-sanche requested review from a team as code owners December 16, 2020 23:21
@daniel-sanche daniel-sanche changed the base branch from support_http_requests to master December 16, 2020 23:21
Copy link
Contributor

@0xSage 0xSage left a comment

Choose a reason for hiding this comment

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

Food for thought:

  1. Will users be able to also modify additional fields like timestamp, insertID, etc permitted by the spec
  2. What about letting users define extras at the log client level, e.g. client.setup_logging(extras=...)
  3. Will you/do you need to communicate in documentation to users that this is only enabled for AppEngine

@daniel-sanche
Copy link
Contributor Author

That's all really good feedback:

  1. This is probably one of the things we'd want to keep consistent across languages. Are the other libraries permissive about overwriting those fields?
  2. That's a great suggestion. I might consider making another PR for that before cutting this release.
  3. My plan was to keep this minimally documented for now (and just point customers to it when needed), and document it better when it works on all environments. But if you have other ideas or suggestions I'm interested in hearing them

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. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log statements are not grouped to parent request in App Engine Standard P3
2 participants