dd-trace-rb
dd-trace-rb copied to clipboard
Instrument gems that are required after `Datadog.configure`
What does this PR do?
When Datadog.configure tries to instrument a gem but that gem is not loaded it currently gives up.
With this PR, it now registers a hook on the Kernel.require method that will instrument the respective gem when that gem is loaded.
Motivation:
Additional Notes:
How to test the change?
For Datadog employees:
- [ ] If this PR touches code that signs or publishes builds or packages, or handles
credentials of any kind, I've requested a review from
@DataDog/security-design-and-guidance. - [ ] This PR doesn't touch any of that.
To do
- [ ] Test this with all combinations of integrations we support (e.g. load
activesupportbeforerails. Loadrailsbeforeactivesupport. Same fortyphoeusandethon.)
Datadog Report
Branch report: auto-patch
Commit report: c46ea29
Test service: dd-trace-rb
:x: 36 Failed (0 Known Flaky), 18541 Passed, 1357 Skipped, 3m 20.26s Total Time
:x: Failed Tests (36)
This report shows up to 5 failed tests.
-
Datadog::Tracing::Contrib::Extensions for Datadog.configure calling c.tracing.instrument for an integration that is available and compatible and loaded behaves like patches immediately configures & patches the integration-rspec- DetailsExpand for error
ndefined method \`gem_load_paths' for #<Class:0x00005566f80daae8> ailure/Error: integration.class.gem_load_paths.each do |require_path| Contrib::Kernel.on_require(require_path) do "Loaded '#{require_path}' for integration '#{integration.name}', instrumenting it." end patch_integration(integration, omit_log) .. -
Datadog::Tracing::Contrib::Extensions for Datadog.configure calling c.tracing.instrument for an integration that is available and compatible and loaded behaves like patches immediately does not register require monitor-rspec- DetailsExpand for error
Datadog::Tracing::Contrib::Kernel::Patcher).patch(no args) expected: 0 times with any arguments received: 1 time ailure/Error: Contrib::Kernel::Patcher.patch # Will only execute once (Datadog::Tracing::Contrib::Kernel::Patcher).patch(no args) expected: 0 times with any arguments received: 1 time hared Example Group: "patches immediately" called from ./spec/datadog/tracing/contrib/extensions_spec.rb:176 .. -
Datadog::Tracing::Contrib::Extensions for Datadog.configure calling c.tracing.instrument for an integration that is available and compatible and loaded behaves like patches immediately sends a telemetry integrations change event-rspec- DetailsExpand for error
ndefined method \`gem_load_paths' for #<Class:0x00005566f80daae8> ailure/Error: integration.class.gem_load_paths.each do |require_path| Contrib::Kernel.on_require(require_path) do "Loaded '#{require_path}' for integration '#{integration.name}', instrumenting it." end patch_integration(integration, omit_log) .. -
Datadog::Tracing::Contrib::Extensions for Datadog.configure calling c.tracing.instrument for an integration that is available and compatible and not loaded attempts to instrument when gem is available and compatible-rspec- DetailsExpand for error
ndefined method \`gem_load_paths' for #<Class:0x00005566f80daae8> ailure/Error: integration.class.gem_load_paths.each do |require_path| Contrib::Kernel.on_require(require_path) do "Loaded '#{require_path}' for integration '#{integration.name}', instrumenting it." end patch_integration(integration, omit_log) .. -
Datadog::Tracing::Contrib::Extensions for Datadog.configure calling c.tracing.instrument for an integration that is available and compatible and not loaded behaves like registers require monitor configures & patches the integration-rspec- DetailsExpand for error
ndefined method \`gem_load_paths' for #<Class:0x00005566f80daae8> ailure/Error: integration.class.gem_load_paths.each do |require_path| Contrib::Kernel.on_require(require_path) do "Loaded '#{require_path}' for integration '#{integration.name}', instrumenting it." end patch_integration(integration, omit_log) ..
Benchmarks
Benchmark execution time: 2025-03-14 20:41:44
Comparing candidate commit c46ea29041b6ecb7713e25495fc1b929ea1390cc in PR branch auto-patch with baseline commit 65b290187101178ce673eb45263fe9c70eb542c7 in branch master.
Found 0 performance improvements and 0 performance regressions! Performance is the same for 31 metrics, 2 unstable metrics.