Skip to content

Commit

Permalink
fix bad merge
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoCaso committed Jul 10, 2023
1 parent f2dfac5 commit 4308a92
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 60 deletions.
24 changes: 8 additions & 16 deletions lib/datadog/appsec/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -96,33 +92,30 @@ 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'
else
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)
Expand All @@ -136,7 +129,6 @@ def self.add_settings!(base)
DEFAULT_APPSEC_AUTOMATED_TRACK_USER_EVENTS_MODE
end
end
o.lazy
end
end
end
Expand Down
8 changes: 2 additions & 6 deletions lib/datadog/ci/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/datadog/ci/contrib/cucumber/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
9 changes: 7 additions & 2 deletions lib/datadog/ci/contrib/minitest/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ 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|
o.default { Datadog.configuration.service_without_fallback || Ext::SERVICE_NAME }
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
Expand Down
3 changes: 1 addition & 2 deletions lib/datadog/ci/contrib/rspec/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/core/configuration/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down
16 changes: 4 additions & 12 deletions lib/datadog/core/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -432,7 +430,7 @@ def initialize(*_)
end
end

option :opts, default: ->(_i) { {} }, lazy: true
option :opts, default: ->(_i) { {} }
option :statsd
end

Expand All @@ -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
Expand All @@ -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
Expand All @@ -482,7 +477,7 @@ def initialize(*_)
# @return [Hash<String,String>]
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|
Expand Down Expand Up @@ -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).
Expand All @@ -533,7 +527,7 @@ def initialize(*_)
# @default `->{ Time.now }`
# @return [Proc<Time>]
option :time_now_provider do |o|
o.default { ::Time.now }
o.experimental_default_proc { ::Time.now }

o.on_set do |time_provider|
Core::Utils::Time.now_provider = time_provider
Expand All @@ -555,8 +549,6 @@ def initialize(*_)
option :version do |o|
# NOTE: version also gets set as a side effect of tags. See the WORKAROUND note in #initialize for details.
o.env_var Core::Environment::Ext::ENV_VERSION
o.default { nil }
o.lazy
end

# Client-side telemetry configuration
Expand Down
14 changes: 3 additions & 11 deletions lib/datadog/tracing/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ def self.extended(base)
end
end
end
o.lazy
end
end

Expand All @@ -366,14 +365,10 @@ def self.extended(base)
end
end

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

Expand Down Expand Up @@ -401,7 +396,7 @@ def self.extended(base)
#
# @default `{}`
# @return [Hash,nil]
option :writer_options, default: ->(_i) { {} }, lazy: true
option :writer_options, default: ->(_i) { {} }

# Client IP configuration
# @public_api
Expand Down Expand Up @@ -432,7 +427,6 @@ def self.extended(base)
# ENABLED env var takes precedence over deprecated DISABLED
val_to_bool(ENV[Tracing::Configuration::Ext::ClientIp::ENV_ENABLED] || enabled)
end
o.lazy
end

# An optional name of a custom header to resolve the client IP from.
Expand All @@ -441,8 +435,6 @@ def self.extended(base)
# @return [String,nil]
option :header_name do |o|
o.env_var Tracing::Configuration::Ext::ClientIp::ENV_HEADER_NAME
o.default { nil }
o.lazy
end
end

Expand Down
27 changes: 18 additions & 9 deletions lib/datadog/tracing/contrib/opensearch/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,39 @@ module Configuration
# @public_api
class Settings < Contrib::Configuration::Settings
option :enabled do |o|
o.default { env_to_bool(Ext::ENV_ENABLED, true) }
o.lazy
o.env_var Ext::ENV_ENABLED
o.default true
o.setter do |value|
val_to_bool(value)
end
end

option :analytics_enabled do |o|
o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, false) }
o.lazy
o.env_var Ext::ENV_ANALYTICS_ENABLED, false
o.default false
o.setter do |value|
val_to_bool(value)
end
end

option :analytics_sample_rate do |o|
o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) }
o.lazy
o.env_var Ext::ENV_ANALYTICS_SAMPLE_RATE
o.default 1.0
o.setter do |value|
val_to_float(value)
end
end

option :quantize, default: {}

option :service_name do |o|
o.default do
o.env_var Ext::ENV_SERVICE_NAME
o.setter do |value|
Contrib::SpanAttributeSchema.fetch_service_name(
Ext::ENV_SERVICE_NAME,
value,
Ext::DEFAULT_PEER_SERVICE_NAME
)
end
o.lazy
end
end
end
Expand Down

0 comments on commit 4308a92

Please sign in to comment.