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!: Infer default resource in logger #315

Merged
merged 13 commits into from Jun 18, 2021

Conversation

daniel-sanche
Copy link
Contributor

We recently added functionality to the library to detect the monitored resource type based on the environment the code is running in (#200, #207). Starting with v3.0.0, this detected data should be populated by default by default when sending new logs, rather than defaulting to global.

This behaviour is already in place when using the logging handlers with the logging stdlib. Now calling the library methods directly will behave consistently

Fixes #239

@daniel-sanche daniel-sanche requested review from a team as code owners June 4, 2021 22:59
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jun 4, 2021
@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/python-logging API. label Jun 4, 2021
@daniel-sanche daniel-sanche changed the title feat: Infer default resource by default feat!: Infer default resource by default Jun 4, 2021
@daniel-sanche daniel-sanche changed the base branch from master to v3.0.0 June 11, 2021 20:19
@daniel-sanche daniel-sanche added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 11, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 11, 2021
@daniel-sanche daniel-sanche added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 11, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 11, 2021
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
@daniel-sanche daniel-sanche added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 15, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 15, 2021
daniel-sanche and others added 2 commits June 15, 2021 16:07
* added code to remove extra topics in snippet tests

* fixed lint issue
Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:58c7342b0bccf85028100adaa3d856cb4a871c22ca9c01960d996e66c40548ce
Copy link

@simonz130 simonz130 left a comment

Choose a reason for hiding this comment

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

This looks like a small improvement but this is actually huge!!!

Thanks Dan!

labels (Optional[dict]): Mapping of default labels for entries written
via this logger.

"""
if not resource:
# infer the correct monitored resource from the local environment
resource = detect_resource(client.project)

Choose a reason for hiding this comment

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

will this default to "global" in case the environment wasn't detected? (i.e. the code is running in dataflow job)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, global is the fallback for detect_resource

@daniel-sanche daniel-sanche requested a review from a team as a code owner June 17, 2021 20:37
@daniel-sanche daniel-sanche requested review from dandhlee and removed request for a team June 17, 2021 20:37
@daniel-sanche daniel-sanche added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 18, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 18, 2021
@daniel-sanche daniel-sanche changed the title feat!: Infer default resource by default feat!: Infer default resource in logger Jun 18, 2021
@daniel-sanche daniel-sanche merged commit d305a2e into v3.0.0 Jun 18, 2021
@daniel-sanche daniel-sanche deleted the change-default-resource-2 branch June 18, 2021 17:55
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.

change default resource
3 participants