Class: Datadog::Configuration::Settings
- Inherits:
-
Object
- Object
- Datadog::Configuration::Settings
- 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
-
#initialize(*_) ⇒ Settings
constructor
A new instance of Settings.
- #logger=(logger) ⇒ Object
-
#runtime_metrics(options = nil) ⇒ Object
Backwards compatibility for configuring runtime metrics e.g.
-
#tracer(options = nil) ⇒ Object
Backwards compatibility for configuring tracer e.g.
- #tracer=(tracer) ⇒ Object
Methods included from Base
Constructor Details
#initialize(*_) ⇒ Settings
Returns a new instance of Settings.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ddtrace/configuration/settings.rb', line 19 def initialize(*_) super # WORKAROUND: The values for services, version, and env can get set either directly OR as a side effect of # accessing tags (reading or writing). This is of course really confusing and error-prone, e.g. in an app # WITHOUT this workaround where you define `DD_TAGS=env:envenvtag,service:envservicetag,version:envversiontag` # and do: # # puts Datadog.configuration.instance_exec { "#{service} #{env} #{version}" } # Datadog.configuration.tags # puts Datadog.configuration.instance_exec { "#{service} #{env} #{version}" } # # the output will be: # # [empty] # envservicetag envenvtag envversiontag # # That is -- the proper values for service/env/version are only set AFTER something accidentally or not triggers # the resolution of the tags. # This is really confusing, error prone, etc, so calling tags here is a really hacky but effective way to # avoid this. I could not think of a better way of fixing this issue without massive refactoring of tags parsing # (so that the individual service/env/version get correctly set even from their tags values, not as a side # effect). Sorry :( end |
Instance Method Details
#logger=(logger) ⇒ Object
134 135 136 |
# File 'lib/ddtrace/configuration/settings.rb', line 134 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
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/ddtrace/configuration/settings.rb', line 213 def runtime_metrics( = nil) settings = get_option(:runtime_metrics) return settings if .nil? # If options were provided (old style) then raise warnings and apply them: # TODO: Raise deprecation warning settings.enabled = [:enabled] if .key?(:enabled) settings.statsd = [:statsd] if .key?(:statsd) settings end |
#tracer(options = nil) ⇒ Object
Backwards compatibility for configuring tracer e.g. c.tracer debug: true
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/ddtrace/configuration/settings.rb', line 358 def tracer( = nil) settings = get_option(:tracer) return settings if .nil? # If options were provided (old style) then raise warnings and apply them: = .dup if .key?(:log) # TODO: Raise deprecation warning get_option(:logger).instance = .delete(:log) end if .key?(:tags) # TODO: Raise deprecation warning set_option(:tags, .delete(:tags)) end if .key?(:env) # TODO: Raise deprecation warning set_option(:env, .delete(:env)) end if .key?(:debug) # TODO: Raise deprecation warning get_option(:diagnostics).debug = .delete(:debug) end if .key?(:partial_flush) # TODO: Raise deprecation warning settings.partial_flush.enabled = .delete(:partial_flush) end if .key?(:min_spans_before_partial_flush) # TODO: Raise deprecation warning settings.partial_flush.min_spans_threshold = .delete(:min_spans_before_partial_flush) end # Forward remaining options to settings .each do |key, value| setter = :"#{key}=" settings.send(setter, value) if settings.respond_to?(setter) end end |
#tracer=(tracer) ⇒ Object
402 403 404 |
# File 'lib/ddtrace/configuration/settings.rb', line 402 def tracer=(tracer) get_option(:tracer).instance = tracer end |