Module: Datadog::Tracing::Contrib::AutoInstrument

Defined in:
lib/datadog/tracing/contrib/auto_instrument.rb

Overview

Extensions for auto instrumentation added to the base library AutoInstrumentation enables all integration

Class Method Summary collapse

Class Method Details

.patch_all!Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/datadog/tracing/contrib/auto_instrument.rb', line 25

def self.patch_all!
  integrations = []

  Contrib::REGISTRY.each do |integration|
    # some instrumentations are automatically enabled when the `rails` instrumentation is enabled,
    # patching them on their own automatically outside of the rails integration context would
    # cause undesirable service naming, so we exclude them based their auto_instrument? setting.
    # we also don't want to mix rspec/cucumber integration in as rspec is env we run tests in.
    next unless integration.klass.auto_instrument?

    integrations << integration.name
  end

  Datadog.configure do |c|
    # Ignore any instrumentation load errors (otherwise it might spam logs)
    c.tracing.ignore_integration_load_errors = true

    # Activate instrumentation for each integration
    integrations.each do |integration_name|
      c.tracing.instrument integration_name
    end
  end
end