-
Notifications
You must be signed in to change notification settings - Fork 394
Open
Labels
bugInvolves a bugInvolves a bugcommunityWas opened by a community memberWas opened by a community member
Description
Tracer Version(s)
2.19.0
Ruby Version(s)
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin22]
Relevent Library and Version(s)
No response
Bug Report
After upgrading to Datadog 2.19.0, there's an issue with constant resolution when using rails runner
to execute Ruby files. The issue occurs when a script tries to reference constants defined within a module namespace that were loaded during Rails initialization.
The issue appears to be related the patching of Kernel.load
. If I comment out lines 78-110 of lib/datadog/tracing/contrib/rails/runner.rb, the bug goes away.
Reproduction Code
- Create a new Rails application:
rails new bug --minimal
- Add datadog 2.18.0 to the Gemfile:
gem 'datadog', '2.18.0'
- Create a file
config/initializers/datadog.rb
:
require 'datadog/tracing'
Datadog.configure do |c|
c.tracing.instrument :rails
end
- Create a file
config/initializers/example_module.rb
:
module ExampleNamespace
module Jobs
end
end
- Create a file
lib/tasks/example_task.rb
:
module ExampleNamespace
puts Jobs.name
end
- Run the task, it should print "ExampleNamespace::Jobs":
bundle exec rails runner lib/tasks/example_task.rb
- Upgrade to datadog 2.19.0 in Gemfile
gem 'datadog', '2.18.0'
- Run the task, it should fail:
bundle exec rails runner lib/tasks/example_task.rb
Configuration Block
See above
Error Logs
N/A
Operating System
Darwin Kernel Version 24.5.0 (but also repro'd on Linux)
How does Datadog help you?
No response
Metadata
Metadata
Assignees
Labels
bugInvolves a bugInvolves a bugcommunityWas opened by a community memberWas opened by a community member