-
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
Add an Enabled
method to Logger
#4995
Comments
This invalidates this rejected proposal https://github.com/open-telemetry/opentelemetry-go/blob/main/log/DESIGN.md#add-xyz-method-to-logger. I have put the issue to GA project to at least discuss it before we moving it to post-GA. |
This will be probably also handy for implementing following bridges: |
Also, possibly, |
This was the idea
As far as I remember, the SDK's logger provider configuration does not accept a severity level. Same for logger method. I think that without any of it adding Enabled to the Bridge API would not make much sense. |
For logrus I think the bridge would implement https://pkg.go.dev/github.com/sirupsen/logrus#Hook |
What about No-Op |
I also think it should be added to the pipeline. If an exporter is only configured to export at a min level there needs to be a way to tell the SDK and user not to do things. This is an operator concern, not one for instrumentation. |
Use cases from other languages
Originally posted by @lalitb in open-telemetry/opentelemetry-specification#3917 (comment) |
While building out the
slog
bridge, it seems like having anEnabled
method will be needed (originally proposed by @jba in #4809 (comment)).From the bridge point of view if the log API requires it to respond to users with if the logging handler is going to actually log something for a context and severity level it needs to know what the implementation of the
Logger
will do.It is not sufficient to track this in the bridge. If the bridge accepts some sort of minimum level things will be logged at it can be different than what the
LoggerProvider
that bridge also accepts is configured to minimally log. This is not a sufficient solution when the bridge needs to provide this information.Additionally, when a bridge doesn't need to provide this information to the log API, it may still optimize its operation internally by checking if a log record is going to be recorded before calling
Logger.Emit
. This may be decent optimization for many bridges.The text was updated successfully, but these errors were encountered: