lib/instana/frameworks/rails.rb in instana-1.201.0 vs lib/instana/frameworks/rails.rb in instana-1.202.0
- old
+ new
@@ -1,13 +1,10 @@
# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2016
if ::Rails::VERSION::MAJOR < 3
::Rails.configuration.after_initialize do
- # In Rails, let's use the Rails logger
- ::Instana.logger = ::Rails.logger if ::Rails.logger
-
if ::Instana.config[:tracing][:enabled]
::Instana.logger.debug "Instrumenting Rack"
::Rails.configuration.middleware.insert 0, ::Instana::Rack
else
::Instana.logger.info "Rack: Tracing disabled via config. Not enabling middleware."
@@ -15,11 +12,14 @@
end
else
module ::Instana
class Railtie < ::Rails::Railtie
initializer 'instana.rack' do |app|
- # In Rails, let's use the Rails logger
- ::Instana.logger = ::Rails.logger if ::Rails.logger
+ # Configure the Instrumented Logger
+ if ::Instana.config[:logging][:enabled] && !ENV.key?('INSTANA_TEST')
+ logger = ::Instana::InstrumentedLogger.new('/dev/null')
+ Rails.logger.extend(ActiveSupport::Logger.broadcast(logger))
+ end
if ::Instana.config[:tracing][:enabled]
::Instana.logger.debug "Instrumenting Rack"
app.config.middleware.insert 0, ::Instana::Rack
else