Module: Datadog::Tracing::Contrib::Rails::Command

Defined in:
lib/datadog/tracing/contrib/rails/runner.rb

Overview

The instrumentation target, Rails::Command::RunnerCommand is only loaded right before ‘bin/rails runner` is executed. This means there’s not much opportunity to patch it ahead of time. To ensure we can patch it successfully, we patch it’s caller, Command and promptly patch Rails::Command::RunnerCommand when it is loaded.

Instance Method Summary collapse

Instance Method Details

#find_by_namespace(*args) ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/datadog/tracing/contrib/rails/runner.rb', line 81

def find_by_namespace(*args)
  ret = super
  # Patch RunnerCommand if it is loaded and not already patched.
  if defined?(::Rails::Command::RunnerCommand) && !(::Rails::Command::RunnerCommand < Runner)
    ::Rails::Command::RunnerCommand.prepend(Runner)
  end
  ret
end