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

improve error message #2937

Merged
merged 2 commits into from
Jun 14, 2022
Merged

improve error message #2937

merged 2 commits into from
Jun 14, 2022

Conversation

paulnpdev
Copy link
Member

improved error message

Because the existing message looks like an Error, but is really only a Debug "comment" and occurs with correct code.

N/A

N/A

NO

@paulnpdev paulnpdev requested a review from a team as a code owner June 2, 2022 17:04
@@ -60,7 +60,7 @@ func (c *Collection) logError(key Key, err error) {
errCount := atomic.AddInt64(&c.errCount, 1)
if errCount%errCountLogThreshold == 0 {
// log only every 'x' errors to reduce mem allocs and to avoid log noise
c.logger.Debug("Failed to fetch key from dynamic config", tag.Key(key.String()), tag.Error(err))
c.logger.Debug("No such key in dynamic config, using default", tag.Key(key.String()), tag.Error(err))
Copy link
Member

Choose a reason for hiding this comment

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

Key not found might be the case of what you see, but the code did not guarantee that it is only case. Any error while trying to fetch the key will end up here. For example if lookup for a key of value int and the value cannot be convert to a int will also end up this log line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Shouldn't we distinguish those cases and log them differently? Those shouldn't be "Debug" level logs, they represent significant coding errors, no?

Copy link
Member

Choose a reason for hiding this comment

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

We could, the key not found is represent as sentinel error errKeyNotPresent. It might not be coding errors, it could be wrong dynamic config value, but agree that also worth a higher level of logging.
Another sentinel error is errNoMatchingConstraint which is also not a real error and should be debug level.
So if we want do some change here, we could check if err == errKeyNotPresent || err == errNoMatchingConstraint, do debug log, otherwise it should be a warning log.

Copy link
Member

Choose a reason for hiding this comment

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

If we do so, the 2 sentinel error probably should be exported because other dynamic config client implementations will need to return the same error for same cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

do you not agree that (considering that the log message is only Debug anyway) that the change to the wording is still an improvement?

I agree with but don't have time to undertake the work you're proposing.

Note that I've added another file to the PR

@paulnpdev paulnpdev merged commit 1dade46 into master Jun 14, 2022
@paulnpdev paulnpdev deleted the improved-error-message branch June 14, 2022 23:33
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