Module: Datadog::Tracing::Contrib::Configurable::InstanceMethods
- Defined in:
- lib/datadog/tracing/contrib/configurable.rb
Overview
Configurable instance behavior for integrations
Instance Method Summary collapse
-
#configuration(matcher = :default) ⇒ Object
Get matching configuration by matcher.
-
#configurations ⇒ Object
Returns all registered matchers and their respective configurations.
-
#configure(matcher = :default, options = {}, &block) ⇒ Object
Create or update configuration associated with ‘matcher` with the provided `options` and `&block`.
-
#default_configuration ⇒ Datadog::Tracing::Contrib::Configuration::Settings
Returns the integration-specific configuration object.
-
#reset_configuration! ⇒ Object
Resets all configuration options.
-
#resolve(value) ⇒ Object
Resolves the matching configuration for integration-specific value.
Instance Method Details
#configuration(matcher = :default) ⇒ Object
Get matching configuration by matcher. If no match, returns the default configuration instance.
23 24 25 26 27 |
# File 'lib/datadog/tracing/contrib/configurable.rb', line 23 def configuration(matcher = :default) return default_configuration if matcher == :default resolver.get(matcher) || default_configuration end |
#configurations ⇒ Object
Returns all registered matchers and their respective configurations.
38 39 40 |
# File 'lib/datadog/tracing/contrib/configurable.rb', line 38 def configurations resolver.configurations.merge(default: default_configuration) end |
#configure(matcher = :default, options = {}, &block) ⇒ Object
Create or update configuration associated with ‘matcher` with the provided `options` and `&block`.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/datadog/tracing/contrib/configurable.rb', line 44 def configure(matcher = :default, = {}, &block) config = if matcher == :default default_configuration else # Get or add the configuration resolver.get(matcher) || resolver.add(matcher, new_configuration) end # Apply the settings config.configure(, &block) if config config end |
#default_configuration ⇒ Datadog::Tracing::Contrib::Configuration::Settings
Returns the integration-specific configuration object.
If one does not exist, invoke #new_configuration a memoize its value.
69 70 71 |
# File 'lib/datadog/tracing/contrib/configurable.rb', line 69 def default_configuration @default_configuration ||= new_configuration end |
#reset_configuration! ⇒ Object
Resets all configuration options
58 59 60 61 |
# File 'lib/datadog/tracing/contrib/configurable.rb', line 58 def reset_configuration! @resolver = nil @default_configuration = nil end |
#resolve(value) ⇒ Object
Resolves the matching configuration for integration-specific value. If no match, returns the default configuration instance.
31 32 33 34 35 |
# File 'lib/datadog/tracing/contrib/configurable.rb', line 31 def resolve(value) return default_configuration if value == :default resolver.resolve(value) || default_configuration end |