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

fix(logging): do not panic in library code #3076

Merged
merged 13 commits into from Oct 29, 2020
Merged

fix(logging): do not panic in library code #3076

merged 13 commits into from Oct 29, 2020

Conversation

0xSage
Copy link
Contributor

@0xSage 0xSage commented Oct 23, 2020

fixes: #1862

Changes:

  • No longer panic on User introduced errors. Instead we log the error and let program proceed
  • We log.Fatalf("ptypes.TimestampProto(time.Unix(0,0)) failed: %v", err) to exit program, since it's a fatal error/likely not induced by Users

@0xSage 0xSage added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: logging Issues related to the Cloud Logging API. automerge Merge the pull request once unit tests and other checks pass. lang: go Issues specific to Go. labels Oct 23, 2020
@0xSage 0xSage self-assigned this Oct 23, 2020
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 23, 2020
@gcf-merge-on-green
Copy link
Contributor

Your PR has attempted to merge for 3 hours. Please check that all required checks have passed, you have an automerge label, and that all your reviewers have approved the PR

@gcf-merge-on-green
Copy link
Contributor

Merge-on-green attempted to merge your PR for 6 hours, but it was not mergeable because either one of your required status checks failed, or one of your required reviews was not approved. Learn more about your required status checks here: https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks. You can remove and reapply the label to re-run the bot.

1 similar comment
@gcf-merge-on-green
Copy link
Contributor

Merge-on-green attempted to merge your PR for 6 hours, but it was not mergeable because either one of your required status checks failed, or one of your required reviews was not approved. Learn more about your required status checks here: https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks. You can remove and reapply the label to re-run the bot.

@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Oct 23, 2020
logging/logging.go Outdated Show resolved Hide resolved
logging/logging.go Outdated Show resolved Hide resolved
logging/logging.go Outdated Show resolved Hide resolved
@codyoss codyoss changed the title fix(logging): do not panic in library code (#1862) fix(logging): do not panic in library code Oct 23, 2020
@0xSage 0xSage requested a review from codyoss October 23, 2020 20:39
logging/logging.go Outdated Show resolved Hide resolved
@0xSage 0xSage marked this pull request as draft October 27, 2020 17:52
Copy link
Contributor Author

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

After careful consideration:

  1. When r.Request is nil, we pipe error message to errc like @tbpg suggested!

  2. When protoStruct contains non-parseable but VALID JSON, we don't log to user at all because i) they will already know a property didn't parse correctly (see a nil value) ii) It's not a user error and there's nothing the user can do to solve this issue. So we don't log per client library convention to be less verbose.

"libraries shouldn't log" :)

logging/logging.go Outdated Show resolved Hide resolved
@0xSage 0xSage marked this pull request as ready for review October 28, 2020 20:09
@0xSage 0xSage requested a review from tbpg October 28, 2020 20:09
@0xSage 0xSage requested a review from a team as a code owner October 29, 2020 17:54
@0xSage
Copy link
Contributor Author

0xSage commented Oct 29, 2020

@codyoss ready for your review on previous change requested, thanks!

Copy link
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

@0xSage 0xSage added the automerge Merge the pull request once unit tests and other checks pass. label Oct 29, 2020
@gcf-merge-on-green gcf-merge-on-green bot merged commit 529be97 into master Oct 29, 2020
@gcf-merge-on-green gcf-merge-on-green bot deleted the fix1862 branch October 29, 2020 20:36
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Oct 29, 2020
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. lang: go Issues specific to Go. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logging: library code should not crash
3 participants