-
Notifications
You must be signed in to change notification settings - Fork 242
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
Log message passed in progname, not in message parameter #1599
Comments
Could you provide how you do the otel initialization that set the custom logger (e.g. OpenTelemetry::SDK.configure )? Have you tried following config to set the custom logger? OpenTelemetry::SDK.configure do |c|
c.logger = ::Logger.new($stdout, level: <the_level_you_want>) # or any custom logger with ::Logger.new
c.use_all()
end |
Opentelemetry::SDK.configure do |conf|
conf.logger = Rails.logger
end But I beleive that doesn't really matter since I can see that we always pass a So, yes, |
Looking at the Ruby logger source, it also passes a nil message from the So the bug is the ForwardingLogger |
@BrianHawley thanks for the finding. I did little test and I believe you are correct on "ForwardingLogger add method not passing through the block to the logger it's forwarding to". Would you mind to contribute a PR to amend this? |
Also added tests to verify the default forwarding logger level, and to make sure it actually forwards logs. Fixes open-telemetry#1599
@ngoral I fixed ForwardingLogger's if progname.nil?
progname = @progname
end
if message.nil?
if block_given?
message = yield
else
message = progname
progname = @progname
end
end You might prefer to just derive your custom logger from Ruby's Logger class, then change where you're logging to or the formatter. Up to you. |
This seems to also be busted when using Current workaround is |
Description of the bug
When I am trying to run my app with a custom logger, the application fails to start with the following error:
I dug a little into it and can see that
ForwardingLogger
passes what should be a message into aprogname
parameter.In registry/lib/opentelemetry/instrumentation/registry.rb:81 we call
OpenTelemetry.logger.info 'Our message here'
Then in sdk/lib/opentelemetry/sdk/forwarding_logger.rb:48 we receive it as
def info(progname = nil, &block)
thus we get our message in aprogname
.Then it is passed to
def add(severity, message = nil, progname = nil)
in which signature me have message attribute, but when passing it, we set it tonil
:add(Logger::INFO, nil, progname, &block)
.And then we omit the block and pass our
nil
message and a message in aprogname
to the originally selected@logger
:@logger.add(severity, message, progname)
.ActiveSupport::Logger
does just fine, but my logger cannot bear both empty message and block, and I myself find it kind of weird: passing message in a progname.Is it done supposedly for some reason or is it an error?
Share details about your runtime
Operating system details: Linux, Ubuntu 16.04 LTS
RUBY_ENGINE: "ruby"
RUBY_VERSION: "3.2.0"
The text was updated successfully, but these errors were encountered: