module Datadog::Contrib::Extensions::Configuration::Settings

Extensions for Datadog::Configuration::Settings

Constants

InvalidIntegrationError

Public Instance Methods

[](integration_name, key = :default) click to toggle source

For the provided `integration_name`, resolves a matching configuration for the provided integration from an integration-specific `key`.

How the matching is performed is integration-specific.

@param [Symbol] integration_name the integration name @param [Object] key the integration-specific lookup key @return [Datadog::Contrib::Configuration::Settings]

# File lib/ddtrace/contrib/extensions.rb, line 104
def [](integration_name, key = :default)
  integration = fetch_integration(integration_name)
  integration.resolve(key) unless integration.nil?
end
configuration(integration_name, describes = nil) click to toggle source

For the provided `integration_name`, retrieves a configuration previously stored by `#instrument`. Specifically, `describes` should be the same value provided in the `describes:` option for `#instrument`.

If no `describes` value is provided, the default configuration is returned.

@param [Symbol] integration_name the integration name @param [Object] describes the previously configured `describes:` object. If `nil`,

fetches the default configuration

@return [Datadog::Contrib::Configuration::Settings]

# File lib/ddtrace/contrib/extensions.rb, line 119
def configuration(integration_name, describes = nil)
  integration = fetch_integration(integration_name)
  integration.configuration(describes) unless integration.nil?
end
fetch_integration(name) click to toggle source
# File lib/ddtrace/contrib/extensions.rb, line 153
def fetch_integration(name)
  Contrib::REGISTRY[name] ||
    raise(InvalidIntegrationError, "'#{name}' is not a valid integration.")
end
instrument(integration_name, options = {}, &block) click to toggle source
# File lib/ddtrace/contrib/extensions.rb, line 124
def instrument(integration_name, options = {}, &block)
  integration = fetch_integration(integration_name)

  unless integration.nil? || !integration.default_configuration.enabled
    configuration_name = options[:describes] || :default
    filtered_options = options.reject { |k, _v| k == :describes }
    integration.configure(configuration_name, filtered_options, &block)
    instrumented_integrations[integration_name] = integration

    # Add to activation list
    integrations_pending_activation << integration
  end
end
Also aliased as: use
instrumented_integrations() click to toggle source
# File lib/ddtrace/contrib/extensions.rb, line 144
def instrumented_integrations
  @instrumented_integrations ||= {}
end
integrations_pending_activation() click to toggle source
# File lib/ddtrace/contrib/extensions.rb, line 140
def integrations_pending_activation
  @integrations_pending_activation ||= Set.new
end
reduce_log_verbosity() click to toggle source
# File lib/ddtrace/contrib/extensions.rb, line 162
def reduce_log_verbosity
  @reduce_verbosity ||= true
end
reduce_verbosity?() click to toggle source
# File lib/ddtrace/contrib/extensions.rb, line 158
def reduce_verbosity?
  defined?(@reduce_verbosity) ? @reduce_verbosity : false
end
registry() click to toggle source

The registry only holds declarative constant values and cannot be modified. This option is a no-op and will be removed in the future.

@deprecated Use `Datadog.registry` instead

# File lib/ddtrace/contrib/extensions.rb, line 81
def registry
  Datadog.logger.warn('Deprecated access to `Datadog.configuration.registry`, use `Datadog.registry` instead.' \
                      '`Datadog.configuration.registry` will be removed in a future version.')
  Contrib::REGISTRY
end
registry=(_arg) click to toggle source

The registry only holds declarative constant values and cannot be modified. This option is a no-op and will be removed in the future.

@deprecated The registry is now a global constant, and can't be overwritten.

# File lib/ddtrace/contrib/extensions.rb, line 91
def registry=(_arg)
  Datadog.logger.warn('Setting a custom registry is no longer supported and was ignored. ' \
                      'Remove this assignment from your configuration to stop seeing this warning.')
end
reset!() click to toggle source
Calls superclass method
# File lib/ddtrace/contrib/extensions.rb, line 148
def reset!
  instrumented_integrations.clear
  super
end
use(integration_name, options = {}, &block)
Alias for: instrument