diff --git a/lib/datadog/appsec/configuration/settings.rb b/lib/datadog/appsec/configuration/settings.rb index fd95b1f72bd..ccd3b0e67df 100644 --- a/lib/datadog/appsec/configuration/settings.rb +++ b/lib/datadog/appsec/configuration/settings.rb @@ -55,27 +55,23 @@ def self.add_settings!(base) option :ruleset do |o| o.env_var 'DD_APPSEC_RULES' - o.default { DEFAULT_APPSEC_RULESET } - o.lazy + o.default DEFAULT_APPSEC_RULESET end option :ip_denylist do |o| - o.default { [] } - o.lazy + o.default [] end option :user_id_denylist do |o| - o.default { [] } - o.lazy + o.default [] end option :waf_timeout do |o| o.env_var 'DD_APPSEC_WAF_TIMEOUT' - o.default { DEFAULT_APPSEC_WAF_TIMEOUT } # us + o.default DEFAULT_APPSEC_WAF_TIMEOUT # us o.setter do |v| Datadog::Core::Utils::Duration.call(v.to_s, base: :us) end - o.lazy end option :waf_debug do |o| @@ -96,20 +92,18 @@ def self.add_settings!(base) option :obfuscator_key_regex do |o| o.env_var 'DD_APPSEC_OBFUSCATION_PARAMETER_KEY_REGEXP' - o.default { DEFAULT_OBFUSCATOR_KEY_REGEX } - o.lazy + o.default DEFAULT_OBFUSCATOR_KEY_REGEX end option :obfuscator_value_regex do |o| o.env_var 'DD_APPSEC_OBFUSCATION_PARAMETER_VALUE_REGEXP' - o.default { DEFAULT_OBFUSCATOR_VALUE_REGEX } - o.lazy + o.default DEFAULT_OBFUSCATOR_VALUE_REGEX end settings :track_user_events do option :enabled do |o| o.env_var 'DD_APPSEC_AUTOMATED_USER_EVENTS_TRACKING' - o.default { DEFAULT_APPSEC_AUTOMATED_TRACK_USER_EVENTS_ENABLED } + o.default DEFAULT_APPSEC_AUTOMATED_TRACK_USER_EVENTS_ENABLED o.setter do |v| if v v.to_s != 'disabled' @@ -117,12 +111,11 @@ def self.add_settings!(base) false end end - o.lazy end option :mode do |o| o.env_var 'DD_APPSEC_AUTOMATED_USER_EVENTS_TRACKING' - o.default { DEFAULT_APPSEC_AUTOMATED_TRACK_USER_EVENTS_MODE } + o.default DEFAULT_APPSEC_AUTOMATED_TRACK_USER_EVENTS_MODE o.setter do |v| string_value = v.to_s if APPSEC_VALID_TRACK_USER_EVENTS_MODE.include?(string_value) @@ -136,7 +129,6 @@ def self.add_settings!(base) DEFAULT_APPSEC_AUTOMATED_TRACK_USER_EVENTS_MODE end end - o.lazy end end end diff --git a/lib/datadog/ci/configuration/settings.rb b/lib/datadog/ci/configuration/settings.rb index 16681cdbd01..e0dfdf42e71 100644 --- a/lib/datadog/ci/configuration/settings.rb +++ b/lib/datadog/ci/configuration/settings.rb @@ -38,14 +38,10 @@ def self.add_settings!(base) # TODO: Deprecate in the next major version, as `instrument` better describes this method's purpose alias_method :use, :instrument - option :trace_flush do |o| - o.default { nil } - o.lazy - end + option :trace_flush option :writer_options do |o| - o.default { {} } - o.lazy + o.default {} end end end diff --git a/lib/datadog/ci/contrib/cucumber/configuration/settings.rb b/lib/datadog/ci/contrib/cucumber/configuration/settings.rb index 854fb33d054..e16c44dcff9 100644 --- a/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +++ b/lib/datadog/ci/contrib/cucumber/configuration/settings.rb @@ -21,7 +21,6 @@ class Settings < Datadog::Tracing::Contrib::Configuration::Settings option :service_name do |o| o.default { Datadog.configuration.service_without_fallback || Ext::SERVICE_NAME } - o.lazy end option :operation_name do |o| diff --git a/lib/datadog/ci/contrib/minitest/configuration/settings.rb b/lib/datadog/ci/contrib/minitest/configuration/settings.rb index 52970f2799d..e6f600d9652 100644 --- a/lib/datadog/ci/contrib/minitest/configuration/settings.rb +++ b/lib/datadog/ci/contrib/minitest/configuration/settings.rb @@ -12,7 +12,11 @@ module Configuration # TODO: mark as `@public_api` when GA class Settings < Datadog::Tracing::Contrib::Configuration::Settings option :enabled do |o| - o.default { env_to_bool(Ext::ENV_ENABLED, true) } + o.env_var Ext::ENV_ENABLED + o.default true + o.setter do |value| + val_to_bool(value) + end end option :service_name do |o| @@ -20,7 +24,8 @@ class Settings < Datadog::Tracing::Contrib::Configuration::Settings end option :operation_name do |o| - o.default { ENV.key?(Ext::ENV_OPERATION_NAME) ? ENV[Ext::ENV_OPERATION_NAME] : Ext::OPERATION_NAME } + o.env_var Ext::ENV_OPERATION_NAME + o.default Ext::OPERATION_NAME end end end diff --git a/lib/datadog/ci/contrib/rspec/configuration/settings.rb b/lib/datadog/ci/contrib/rspec/configuration/settings.rb index f75f8010746..3ced02447a6 100644 --- a/lib/datadog/ci/contrib/rspec/configuration/settings.rb +++ b/lib/datadog/ci/contrib/rspec/configuration/settings.rb @@ -21,12 +21,11 @@ class Settings < Datadog::Tracing::Contrib::Configuration::Settings option :service_name do |o| o.default { Datadog.configuration.service_without_fallback || Ext::SERVICE_NAME } - o.lazy end option :operation_name do |o| o.env_var Ext::ENV_OPERATION_NAME - o.default ENV[Ext::OPERATION_NAME] + o.default Ext::OPERATION_NAME end end end diff --git a/lib/datadog/core/configuration/base.rb b/lib/datadog/core/configuration/base.rb index aed35c384f3..b8bc0476c17 100644 --- a/lib/datadog/core/configuration/base.rb +++ b/lib/datadog/core/configuration/base.rb @@ -28,7 +28,7 @@ def settings(name, &block) settings_class = new_settings_class(&block) option(name) do |o| - o.default { settings_class.new } + o.default settings_class.new o.resetter do |value| value.reset! if value.respond_to?(:reset!) diff --git a/lib/datadog/core/configuration/settings.rb b/lib/datadog/core/configuration/settings.rb index aca7f7ea12d..bd60b7a66cd 100644 --- a/lib/datadog/core/configuration/settings.rb +++ b/lib/datadog/core/configuration/settings.rb @@ -80,8 +80,6 @@ def initialize(*_) # @return [String,nil] option :api_key do |o| o.env_var Core::Environment::Ext::ENV_API_KEY - o.default { nil } - o.lazy end # Datadog diagnostic settings. @@ -432,7 +430,7 @@ def initialize(*_) end end - option :opts, default: ->(_i) { {} }, lazy: true + option :opts, default: ->(_i) { {} } option :statsd end @@ -446,8 +444,7 @@ def initialize(*_) # NOTE: service also gets set as a side effect of tags. See the WORKAROUND note in #initialize for details. o.env_var Core::Environment::Ext::ENV_SERVICE - o.default { Core::Environment::Ext::FALLBACK_SERVICE_NAME } - o.lazy + o.default Core::Environment::Ext::FALLBACK_SERVICE_NAME # There's a few cases where we don't want to use the fallback service name, so this helper allows us to get a # nil instead so that one can do @@ -470,8 +467,6 @@ def initialize(*_) # @return [String,nil] option :site do |o| o.env_var Core::Environment::Ext::ENV_SITE - o.default { nil } - o.lazy end # Default tags @@ -482,7 +477,7 @@ def initialize(*_) # @return [Hash] option :tags do |o| o.env_var Core::Environment::Ext::ENV_TAGS - o.default { {} } + o.default {} o.setter do |new_value, old_value| tag_list = if new_value && new_value.is_a?(String) val_to_list(new_value, comma_separated_only: false).each_with_object({}) do |tag, tags| @@ -520,7 +515,6 @@ def initialize(*_) # Merge with previous tags (old_value || {}).merge(string_tags) end - o.lazy end # The time provider used by Datadog. It must respect the interface of [Time](https://ruby-doc.org/core-3.0.1/Time.html). @@ -533,7 +527,7 @@ def initialize(*_) # @default `->{ Time.now }` # @return [Proc