-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Connect the Zap logger w/ the otel-go SDK error handler and internal logger #6717
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very interesting choice of the logger implementation... I am a bit nervous about this extra dependency, but I think there is no other option...
question: If we set the logger, does otel not log the errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, the built-in internal logger goes to the console. I don't have any examples lying around, and I would be OK not adopting this line as the error handler is more important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I've wanted to catch up with https://go.googlesource.com/proposal/+/master/design/56345-structured-logging.md, regarding logging APIs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question is, when you call
otel.ErrorHandlerFunc
do you not call the logger in advance? With this setup would errors going to be double logged?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is not the case. The default error handler uses the Go-1.0
log
package, i.e.,log.New(os.Stderr, "", log.LstdFlags)
, while the default internal logger uses logr's "stdr" package, i.e.,stdr.New(log.New(os.Stderr, "", log.LstdFlags|log.Lshortfile))
.I admit I'm not sure whether it's easy/difficult to double-log, but they appear separate. @MadVikingGod would you comment on whether this PR looks sane for a user of
zap
, to configure both error handler and logger?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no problem setting both. We prefer to use error handling to enable users to take action in response to errors. But nothing in the SDK should do both at the same time. Libraries outside of the base otel can't access the logging library.
I don't know about zap, but if you are looking for the info or debug logs you might need to increase zapr verbosity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that with my change, if the collector were configured for verbose logging, then otel-go's debug logging would begin to appear because zapr does the right thing (I haven't verified this). My secondary goal was to ensure consistent formatting w/ the configured logger. Thanks @MadVikingGod