Skip to content

fix(logging): allow nil zones in resource autodetection#3997

Merged
freelerobot merged 2 commits intomasterfrom
fix3990
May 3, 2021
Merged

fix(logging): allow nil zones in resource autodetection#3997
freelerobot merged 2 commits intomasterfrom
fix3990

Conversation

@freelerobot
Copy link
Copy Markdown
Contributor

fixes #3990

@freelerobot freelerobot requested review from a team April 23, 2021 00:24
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Apr 23, 2021
@freelerobot freelerobot self-assigned this Apr 23, 2021
@product-auto-label product-auto-label Bot added the api: logging Issues related to the Cloud Logging API. label Apr 23, 2021
Comment thread logging/logging.go
if cutoff > 0 {
return zone[:cutoff]
}
return zone
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this value is not what is expected should we put zone in at all? Or just ""?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe I can help out here, in my experience, passing in the values causing this to panic (e.g. us16) will work and be accepted by Cloud Logging. I've been using my own autodetect code to stand up our logging client which does this and have had no issues logging:

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We should accept any user specified/custom zones. Per user docs:
CommonResource sets the monitored resource associated with all log entries written from a Logger. If not provided, the resource is automatically detected based on the running environment (on GCE, GCR, GCF and GAE Standard only). This value can be overridden per-entry by setting an Entry's Resource field.

@freelerobot
Copy link
Copy Markdown
Contributor Author

@codyoss , can I bug you for a stampy stamp on this one?

Copy link
Copy Markdown
Member

@codyoss codyoss left a comment

Choose a reason for hiding this comment

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

Lgtm

@freelerobot freelerobot merged commit aded90b into master May 3, 2021
@freelerobot freelerobot deleted the fix3990 branch May 3, 2021 03:01
@freelerobot
Copy link
Copy Markdown
Contributor Author

Lgtm

oh wow, thank you for taking a look on your weekend Cody

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 Cloud 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.

logging: panic in resource dection for Cloud Functions

3 participants