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

Refactor failed heartbeats log #1273

Merged
merged 4 commits into from
Sep 21, 2023

Conversation

jakobht
Copy link
Contributor

@jakobht jakobht commented Sep 20, 2023

What changed?
Refactored the type check to use modern Go

What changed?
In modern go typecasting errors is sometimes not correct as they might be wrapped, the errors.As method is aware of this and checks all wrapped errors

How did you test it?
Tested locally

Potential risks
Worst case we log too much/too little

}
// If the error is a canceled error do not log, as this is expected.
var canceledErr *CanceledError
if errors.As(err, &canceledErr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to reverse the check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, thanks!

Copy link
Contributor

@Groxx Groxx left a comment

Choose a reason for hiding this comment

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

yeah - all this code is stranger than I originally thought too :|

logging on workflow-complete and other "stop the activity" cases should be relatively rare in comparison, and we can filter those out later too if we want. or rewrite this code, it seems unlikely to be doing what it should in those situations.

}
// If the error is a canceled error do not log, as this is expected.
var canceledErr *CanceledError
if canceledErr != nil && !errors.As(err, &canceledErr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

canceledErr is always nil and err is checked for nil inside errors.As.

Copy link
Contributor

Choose a reason for hiding this comment

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

also, maybe put this into a method and add a test so you are 100% sure about the behaviour.
Something like
i.processHearbeatError(err)
and then add unit test with zaptest.Logger.

Copy link
Contributor

@3vilhamster 3vilhamster left a comment

Choose a reason for hiding this comment

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

Please revert recent change :)

Copy link
Contributor

@3vilhamster 3vilhamster left a comment

Choose a reason for hiding this comment

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

LGTM

@jakobht jakobht merged commit cd0c3ad into uber-go:master Sep 21, 2023
timl3136 pushed a commit that referenced this pull request Nov 4, 2023
* Refactored the log type check

* Wrong check - reversed

* Added nil check

* Added tests, and fixed nil error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants