-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Internal Logging #2343
Internal Logging #2343
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2343 +/- ##
=======================================
- Coverage 74.2% 74.2% -0.1%
=======================================
Files 173 175 +2
Lines 12174 12194 +20
=======================================
+ Hits 9043 9057 +14
- Misses 2894 2900 +6
Partials 237 237
|
This is a simple loggin interface to be used interally for the sdk. Included is an exmaple in `namedtracer` run: ``` cd example/namedtracer go run . >/dev/null ```
7cd725b
to
8d0b098
Compare
So I was not aware of the |
UpdateThis now includes a rework of the error handeling. I'm not a fan of the scope creep, but I felt it necessary to have these interfaces work together as much as possible in unison. I simplified how the error handler is managed, and changed it's default to use the internal logger. I also made the default internal logger print Error messages to stderr, this perserves the behavior of the current errorHandler. ConventionsWhen I first started on this because each logging implementation uses different levels internally (logrus uses 1 - -5, but glog, klog, and zap use 1 - 5 etc), I didn't know if there would be an easy convention we could set that would be easy to explain to users. To drive this I experimented with all of the loggers here, and found that MOST logr implementations use 0 as their default, and allow all Error messages. This makes setting a convention easy. To that extent what I set was three different levels Error, Info (lvl 1 off by default for most loggers), and debug (lvl 5 off on all loggers). I just need a bit of help writing the SetLogger documentation to explain how to see the different levels. |
Removed dead code. Merged main to fix tests.
CHANGELOG.md
Outdated
- Added an internal Logger. This can be used by the SDK and API to provide users with feedback of the internal state. To enable verbose logs configure the logger which will print V(1) logs. For debugging information confgure to print V(5) logs. | ||
- Added an internal Logger. | ||
This can be used by the SDK and API to provide users with feedback of the internal state. | ||
To enable verbose logs configure the logger which will print V(1) logs. For debugging information configure to print V(5) logs. (#2343) |
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.
To enable verbose logs configure the logger which will print V(1) logs. For debugging information configure to print V(5) logs. (#2343) | |
To enable verbose logs, configure the logger which will print V(1) logs. For debugging information configure to print V(5) logs. (#2343) |
So I think I might not be expressing my concerns about why we need to changethe error handling well enough. I made a quick demo of what the behavior is right now where we don't touch the error handler, here. Running it you will see:
|
I see your concern. However, personally, I do not like that currently the default ErrorHandler is logging. As for me, the ErrorHandling logging concern could be addressed in a separate PR as a follow-up. I assume we are not planning a release in the following days. Normally I would propose a PR that removes logging from the default error handler (that could be merged even before this PR). However, I do not time to work on that and participate in possible conversations 😞 EDIT: I created a draft PR in browser to express what I mean 😄 #2416 This would also be in line with my comment here: #2343 (comment) |
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.
Outside of the minor changelog suggestions this looks ready to merge.
I think this is a great launch point for our internal logging! Thanks for digging into this. 🚀
I created an issue #2417 and resolved most of my comments. |
func Info(msg string, keysAndValues ...interface{}) { | ||
globalLoggerLock.RLock() | ||
defer globalLoggerLock.RUnlock() | ||
globalLogger.V(1).Info(msg, keysAndValues...) |
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'm curious about the choice of V(1)
and V(5)
. I take it the user shouldn't see OTel-SDK Info messages unless they're debugging, thus Info is V(1)
?
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.
Yeah, the idea was that V(1) is akin to a command line -v
, the extra data that might be helpful.
What is this?
This is an experiment to enable logging from the API and SDK.
It creates a simple user facing interface to set a logger, and then exposes that
logr.Logger
in theinternal/debug
package.What is not included in this PR?
How do you use it?
The simplest way is to run the NamedTracer example. This should output to stderr the only line that was instrumented in the project.
Closes #1068