You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if defined?(Judoscale)
Judoscale.configure do |config|
config.log_level = :warn
end
end
In logs: no INFO messages
Actual
In logs:
INFO -- : [Judoscale] Reporting 40 metrics
Workaround
if defined?(Judoscale)
Judoscale.configure do |config|
config.log_level = :warn
Judoscale::Reporter.instance.logger.log_level = ::Logger::Severity::WARN
end
end
Analysis
There appears to be a race condition between Judoscale::Config.instance and Judoscale::Reporter.instance.logger.
The first time that code is called, it takes Judoscale::Config.instance.log_levelat that moment, and hands it to a new instance LoggerProxy. All later calls hand back the same instance of LoggerProxy. Any later changes to Judoscale::Config.instance.log_level won't be reflected.
…ialized
Fixes#187
Our own Railtie code makes calls to `logger` which might be run before a user's custom `Judoscale.configure` block. We need to allow configuring the log level at any time.
… initialized (#190)
Fixes#187
Our own Railtie code makes calls to `logger` which might be run before a user's custom `Judoscale.configure` block. We need to allow configuring the log level at any time.
Expected
In
config/initializers/judoscale.rb
:In logs: no
INFO
messagesActual
In logs:
Workaround
Analysis
There appears to be a race condition between
Judoscale::Config.instance
andJudoscale::Reporter.instance.logger
.When
Judoscale::Reporter.instance.logger
is called, that calls this code: https://github.com/judoscale/judoscale-ruby/blob/main/judoscale-ruby/lib/judoscale/logger.rb#L9The first time that code is called, it takes
Judoscale::Config.instance.log_level
at that moment, and hands it to a new instanceLoggerProxy
. All later calls hand back the same instance ofLoggerProxy
. Any later changes toJudoscale::Config.instance.log_level
won't be reflected.The
Logger
instance wrapped byLoggerProxy
has no log level set: https://github.com/judoscale/judoscale-ruby/blob/main/judoscale-ruby/lib/judoscale/config.rb#L83Potential Solutions
Judoscale::Config.instance.log_level
withJudoscale::Config.instance.logger
Judoscale::Reporter.instance.logger
whenJudoscale::Config.instance.log_level
changes.The text was updated successfully, but these errors were encountered: