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 label Dec 11, 2020
@google-cla google-cla bot added the cla: yes label Dec 11, 2020
@daniel-sanche daniel-sanche marked this pull request as ready for review Dec 16, 2020
@daniel-sanche daniel-sanche requested review from as code owners Dec 16, 2020
@daniel-sanche daniel-sanche changed the base branch from support_http_requests to master Dec 16, 2020
0xSage
0xSage approved these changes Jan 6, 2021
Copy link
Contributor

@0xSage 0xSage left a comment

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

@daniel-sanche daniel-sanche commented Jan 6, 2021

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

@daniel-sanche daniel-sanche self-assigned this Jan 7, 2021
@daniel-sanche daniel-sanche merged commit 92b287f into master Jan 9, 2021
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants