Class: Datadog::Configuration::Settings

Inherits:
Object
  • Object
show all
Extended by:
Environment::Helpers
Includes:
Options
Defined in:
lib/ddtrace/configuration/settings.rb

Overview

Global configuration settings for the trace library.

Constant Summary

Constants included from Options

Options::InvalidOptionError

Instance Method Summary collapse

Methods included from Environment::Helpers

env_to_bool, env_to_float, env_to_list

Methods included from Options

included

Constructor Details

#initialize(options = {}) ⇒ Settings

Returns a new instance of Settings.



49
50
51
# File 'lib/ddtrace/configuration/settings.rb', line 49

def initialize(options = {})
  configure(options)
end

Instance Method Details

#configure(options = {}) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



53
54
55
56
57
58
59
60
# File 'lib/ddtrace/configuration/settings.rb', line 53

def configure(options = {})
  self.class.options.dependency_order.each do |name|
    next unless options.key?(name)
    respond_to?("#{name}=") ? send("#{name}=", options[name]) : set_option(name, options[name])
  end

  yield(self) if block_given?
end

#distributed_tracingObject



62
63
64
65
66
# File 'lib/ddtrace/configuration/settings.rb', line 62

def distributed_tracing
  # TODO: Move distributed tracing configuration to it's own Settings sub-class
  # DEV: We do this to fake `Datadog.configuration.distributed_tracing.propagation_inject_style`
  self
end

#runtime_metrics(options = nil) ⇒ Object



68
69
70
71
72
73
# File 'lib/ddtrace/configuration/settings.rb', line 68

def runtime_metrics(options = nil)
  runtime_metrics = get_option(:tracer).writer.runtime_metrics
  return runtime_metrics if options.nil?

  runtime_metrics.configure(options)
end

#tracer(options = nil) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/ddtrace/configuration/settings.rb', line 77

def tracer(options = nil)
  tracer = options && options.key?(:instance) ? set_option(:tracer, options[:instance]) : get_option(:tracer)

  tracer.tap do |t|
    unless options.nil?
      t.configure(options)
      t.class.log = options[:log] if options[:log]
      t.set_tags(options[:tags]) if options[:tags]
      t.set_tags(env: options[:env]) if options[:env]
      t.class.debug_logging = options.fetch(:debug, false)
    end
  end
end