Sha256: 1db01f5fe653a0719ea297b6f1c5e20438fddca433ab735d0d0f66bc0c3db279
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
require_relative 'configuration/proxy' require_relative 'configuration/resolver' require_relative 'configuration/pin_setup' module Datadog # Configuration provides a unique access point for configurations class Configuration InvalidIntegrationError = Class.new(StandardError) def initialize(options = {}) @registry = options.fetch(:registry) { Datadog.registry } @wrapped_registry = {} end def [](integration_name) @wrapped_registry[integration_name] ||= Proxy.new(fetch_integration(integration_name)) end def use(integration_name, options = {}) integration = fetch_integration(integration_name) settings = Proxy.new(integration) integration.sorted_options.each do |name| settings[name] = options.fetch(name, settings[name]) end integration.patch if integration.respond_to?(:patch) end def tracer(options = {}) instance = options.fetch(:instance, Datadog.tracer) instance.configure(options) instance.class.log = options[:log] if options[:log] instance.set_tags(options[:tags]) if options[:tags] instance.set_tags(env: options[:env]) if options[:env] instance.class.debug_logging = options.fetch(:debug, false) end private def fetch_integration(name) @registry[name] || raise(InvalidIntegrationError, "'#{name}' is not a valid integration.") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ddtrace-0.13.2 | lib/ddtrace/configuration.rb |
ddtrace-0.13.1 | lib/ddtrace/configuration.rb |