Module: Datadog::Tracing::Contrib::Extensions::Configuration

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

Overview

Configuration methods for Datadog module.

Defined Under Namespace

Modules: Settings

Instance Method Summary collapse

Instance Method Details

#configure(&block) ⇒ Object

TODO: Is is not possible to separate this configuration method TODO: from core ddtrace parts ()e.g. the registry). TODO: Today this method sits here in the ‘Datadog::Tracing::Contrib::Extensions` namespace TODO: but cannot empirically constraints to the contrib domain only. TODO: We should promote most of this logic to core parts of ddtrace.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/datadog/tracing/contrib/extensions.rb', line 62

def configure(&block)
  # Reconfigure core settings
  super(&block)

  # Activate integrations
  configuration = self.configuration.tracing

  if configuration.respond_to?(:integrations_pending_activation)
    ignore_integration_load_errors = if configuration.respond_to?(:ignore_integration_load_errors?)
                                       configuration.ignore_integration_load_errors?
                                     else
                                       false
                                     end

    configuration.integrations_pending_activation.each do |integration|
      next unless integration.respond_to?(:patch)

      # integration.patch returns either true or a hash of details on why patching failed
      patch_results = integration.patch

      next if patch_results == true

      # if patching failed, only log output if verbosity is unset
      # or if patching failure is due to compatibility or integration specific reasons
      next unless !ignore_integration_load_errors ||
        ((patch_results[:available] && patch_results[:loaded]) &&
        (!patch_results[:compatible] || !patch_results[:patchable]))

      desc = "Available?: #{patch_results[:available]}"
      desc += ", Loaded? #{patch_results[:loaded]}"
      desc += ", Compatible? #{patch_results[:compatible]}"
      desc += ", Patchable? #{patch_results[:patchable]}"

      Datadog.logger.warn("Unable to patch #{patch_results[:name]} (#{desc})")
    end

    components.telemetry.integrations_change! if configuration.integrations_pending_activation

    configuration.integrations_pending_activation.clear
  end

  configuration
end