lib/ddtrace/contrib/rails/patcher.rb in ddtrace-0.50.0 vs lib/ddtrace/contrib/rails/patcher.rb in ddtrace-0.51.0
- old
+ new
@@ -1,10 +1,11 @@
require 'ddtrace/contrib/rails/utils'
require 'ddtrace/contrib/rails/framework'
require 'ddtrace/contrib/rails/middlewares'
require 'ddtrace/contrib/rails/log_injection'
require 'ddtrace/contrib/rack/middlewares'
+require 'ddtrace/contrib/semantic_logger/patcher'
require 'ddtrace/utils/only_once'
module Datadog
module Contrib
module Rails
@@ -58,18 +59,19 @@
def add_logger(app)
should_warn = true
# check if lograge key exists
# Note: Rails executes initializers sequentially based on alphabetical order,
- # and lograge config could occur after dd config.
- # Checking for `app.config.lograge.enabled` may yield a false negative.
- # Instead we should naively add custom options if `config.lograge` exists from the lograge Railtie,
- # since the custom options get ignored without lograge explicitly being enabled.
- # See: https://github.com/roidrage/lograge/blob/1729eab7956bb95c5992e4adab251e4f93ff9280/lib/lograge/railtie.rb#L7-L12
- if app.config.respond_to?(:lograge)
- Datadog::Contrib::Rails::LogInjection.add_lograge_logger(app)
- should_warn = false
- end
+ # and lograge config could occur after datadog config.
+ # So checking for `app.config.lograge.enabled` may yield a false negative,
+ # and adding custom options naively if `config.lograge` exists from the lograge Railtie,
+ # is inconsistent since a lograge initializer would override it.
+ # Instead, we patch Lograge `custom_options` internals directly
+ # as part of Rails framework patching
+ # and just flag off the warning log here.
+ # SemanticLogger we similarly patch in the after_initiaize block, and should flag
+ # off the warning log here if we know we'll patch this gem later.
+ should_warn = false if app.config.respond_to?(:lograge) || defined?(::SemanticLogger)
# if lograge isn't set, check if tagged logged is enabled.
# if so, add proc that injects trace identifiers for tagged logging.
if (logger = app.config.logger) &&
defined?(::ActiveSupport::TaggedLogging) &&