Skip to content
This repository was archived by the owner on Aug 13, 2026. It is now read-only.

feat!: Infer default resource in logger - #315

Merged
daniel-sanche merged 13 commits into
v3.0.0from
change-default-resource-2
Jun 18, 2021
Merged

feat!: Infer default resource in logger#315
daniel-sanche merged 13 commits into
v3.0.0from
change-default-resource-2

Conversation

@daniel-sanche

Copy link
Copy Markdown
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 teamJune 4, 2021 22:59
@google-clagoogle-claBot added the cla: yes This human has signed the Contributor License Agreement. label Jun 4, 2021
@product-auto-labelproduct-auto-labelBot added the api: logging Issues related to the googleapis/python-logging API. label Jun 4, 2021
@daniel-sanchedaniel-sanche changed the title feat: Infer default resource by defaultfeat!: Infer default resource by defaultJun 4, 2021
@daniel-sanche
daniel-sanche changed the base branch from master to v3.0.0June 11, 2021 20:19
@daniel-sanchedaniel-sanche added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 11, 2021
@yoshi-kokoroyoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 11, 2021
@daniel-sanchedaniel-sanche added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 11, 2021
@yoshi-kokoroyoshi-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-sanchedaniel-sanche added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 15, 2021
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 15, 2021
daniel-sancheand 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

@simonz130simonz130 left a comment

Copy link
Copy Markdown

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!

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

Copy link
Copy Markdown

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
Copy Markdown
ContributorAuthor

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 ownerJune 17, 2021 20:37
@daniel-sanche
daniel-sanche requested review from dandhlee and removed request for a teamJune 17, 2021 20:37
@daniel-sanchedaniel-sanche added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 18, 2021
@yoshi-kokoroyoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 18, 2021
@daniel-sanchedaniel-sanche changed the title feat!: Infer default resource by defaultfeat!: Infer default resource in loggerJun 18, 2021
@daniel-sanche
daniel-sanche merged commit d305a2e into v3.0.0Jun 18, 2021
@daniel-sanche
daniel-sanche deleted the change-default-resource-2 branch June 18, 2021 17:55
@release-pleaserelease-pleaseBot mentioned this pull request Jan 27, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: loggingIssues related to the googleapis/python-logging API.cla: yesThis 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

@daniel-sanche@simonz130@yoshi-kokoro