# config/initializers/datadog-trace.rb
Rails.configuration.datadog_trace = {
enabled: Rails.env.production?,
}
Datadog::Tracer.log.debug("Rails.configuration.datadog_trace = #{Rails.configuration.datadog_trace.inspect}")
But when booting sidekiq in development, datadog tracer starts recording and attempting to write traces much earlier when sidekiq communicates with redis during startup (after the railtie's before_configuration but before after_initialize):
$ bin/sidekiq
xD, [2017-03-03T00:43:26.295524 #75633] DEBUG -- : using Msgpack encoder
D, [2017-03-03T00:43:27.920030 #75633] DEBUG -- : 'redis-rails' module not found, Datadog 'redis-rails' integration is disabled
D, [2017-03-03T00:44:28.08712 #75633] DEBUG -- : Rails.configuration.datadog_trace = {:enabled=>false}
2017-03-03T00:43:28.142Z 75633 TID-oxhxghe0g INFO: Booting Sidekiq 4.2.9 with redis options {:url=>"redis://localhost:6379/1", :namespace=>"sidekiq"}
D, [2017-03-03T00:43:28.148760 #75633] DEBUG -- : Set pin redis on Redis::Client.
D, [2017-03-03T00:43:28.149140 #75633] DEBUG -- : Get pin from Redis::Client.
D, [2017-03-03T00:43:28.152427 #75633] DEBUG -- : Get pin from Redis::Client.
D, [2017-03-03T00:43:28.152869 #75633] DEBUG -- : Writing 2 spans (enabled: true)
# ... a bunch of other boot stuff
# I added this log statement to the beginning of Datadog::Railtie#after_initialize method for tracing:
D, [2017-03-03T00:43:28.349357 #75633] DEBUG -- : Datadog::Railtie#after_initialize
# (the sidekiq banner and "starting processing" below here)
# now a bunch of:
E, [2017-03-03T00:43:57.192496 #75633] ERROR -- : Failed to open TCP connection to localhost:7777 (Connection refused - connect(2) for "localhost" port 7777)