Module: Datadog::Configuration

Extended by:
Forwardable
Included in:
Datadog
Defined in:
lib/ddtrace/configuration.rb,
lib/ddtrace/configuration/base.rb,
lib/ddtrace/configuration/option.rb,
lib/ddtrace/configuration/options.rb,
lib/ddtrace/configuration/settings.rb,
lib/ddtrace/configuration/pin_setup.rb,
lib/ddtrace/configuration/components.rb,
lib/ddtrace/configuration/option_set.rb,
lib/ddtrace/configuration/option_definition.rb,
lib/ddtrace/configuration/dependency_resolver.rb,
lib/ddtrace/configuration/option_definition_set.rb

Overview

Configuration provides a unique access point for configurations

Defined Under Namespace

Modules: Base, Options Classes: Components, DependencyResolver, Option, OptionDefinition, OptionDefinitionSet, OptionSet, PinSetup, Settings

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configurationObject


14
15
16
# File 'lib/ddtrace/configuration.rb', line 14

def configuration
  @configuration ||= Settings.new
end

Instance Method Details

#configure(target = configuration, opts = {}) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ddtrace/configuration.rb', line 18

def configure(target = configuration, opts = {})
  if target.is_a?(Settings)
    yield(target) if block_given?

    # Build immutable components from settings
    @components ||= nil
    @components = if @components
                    replace_components!(target, @components)
                  else
                    build_components(target)
                  end

    target
  else
    PinSetup.new(target, opts).call
  end
end

#loggerObject


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ddtrace/configuration.rb', line 42

def logger
  if instance_variable_defined?(:@components) && @components
    @temp_logger = nil
    components.logger
  else
    # Use default logger without initializing components.
    # This prevents recursive loops while initializing.
    # e.g. Get logger --> Build components --> Log message --> Repeat...
    @temp_logger ||= begin
      logger = configuration.logger.instance || Datadog::Logger.new(STDOUT)
      logger.level = configuration.diagnostics.debug ? ::Logger::DEBUG : configuration.logger.level
      logger
    end
  end
end

#shutdown!Object


58
59
60
# File 'lib/ddtrace/configuration.rb', line 58

def shutdown!
  components.shutdown! if instance_variable_defined?(:@components) && @components
end