Class: Datadog::Configuration::Settings

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/ddtrace/configuration/settings.rb

Overview

Global configuration settings for the trace library. rubocop:disable Metrics/ClassLength

Instance Method Summary collapse

Methods included from Base

included

Instance Method Details

#logger=(logger) ⇒ Object



101
102
103
# File 'lib/ddtrace/configuration/settings.rb', line 101

def logger=(logger)
  get_option(:logger).instance = logger
end

#runtime_metrics(options = nil) ⇒ Object

Backwards compatibility for configuring runtime metrics e.g. ‘c.runtime_metrics enabled: true`



121
122
123
124
125
126
127
128
129
130
# File 'lib/ddtrace/configuration/settings.rb', line 121

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

  # If options were provided (old style) then raise warnings and apply them:
  # TODO: Raise deprecation warning
  settings.enabled = options[:enabled] if options.key?(:enabled)
  settings.statsd = options[:statsd] if options.key?(:statsd)
  settings
end

#tracer(options = nil) ⇒ Object

Backwards compatibility for configuring tracer e.g. ‘c.tracer debug: true`



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/ddtrace/configuration/settings.rb', line 225

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

  # If options were provided (old style) then raise warnings and apply them:
  options = options.dup

  if options.key?(:log)
    # TODO: Raise deprecation warning
    get_option(:logger).instance = options.delete(:log)
  end

  if options.key?(:tags)
    # TODO: Raise deprecation warning
    set_option(:tags, options.delete(:tags))
  end

  if options.key?(:env)
    # TODO: Raise deprecation warning
    set_option(:env, options.delete(:env))
  end

  if options.key?(:debug)
    # TODO: Raise deprecation warning
    get_option(:diagnostics).debug = options.delete(:debug)
  end

  if options.key?(:partial_flush)
    # TODO: Raise deprecation warning
    settings.partial_flush.enabled = options.delete(:partial_flush)
  end

  if options.key?(:min_spans_before_partial_flush)
    # TODO: Raise deprecation warning
    settings.partial_flush.min_spans_threshold = options.delete(:min_spans_before_partial_flush)
  end

  # Forward remaining options to settings
  options.each do |key, value|
    setter = :"#{key}="
    settings.send(setter, value) if settings.respond_to?(setter)
  end
end

#tracer=(tracer) ⇒ Object



269
270
271
# File 'lib/ddtrace/configuration/settings.rb', line 269

def tracer=(tracer)
  get_option(:tracer).instance = tracer
end