diff --git a/lib/datadog/core/configuration/settings.rb b/lib/datadog/core/configuration/settings.rb index 1fceab20b27..9ba208cc047 100644 --- a/lib/datadog/core/configuration/settings.rb +++ b/lib/datadog/core/configuration/settings.rb @@ -667,13 +667,27 @@ def initialize(*_) # Whether client IP collection is enabled. When enabled client IPs from HTTP requests will # be reported in traces. # + # Usage of the DD_TRACE_CLIENT_IP_HEADER_DISABLED environment variable is deprecated. + # # @see https://docs.datadoghq.com/tracing/configure_data_security#configuring-a-client-ip-header # - # @default The negated value of the `DD_TRACE_CLIENT_IP_HEADER_DISABLED` environment - # variable or `false` if it doesn't exist. + # @default `DD_TRACE_CLIENT_IP_HEADER_ENABLED` environment variable, otherwise `false`. # @return [Boolean] option :enabled do |o| - o.default { !env_to_bool(Tracing::Configuration::Ext::ClientIp::ENV_DISABLED, true) } + o.default do + disabled = env_to_bool(Tracing::Configuration::Ext::ClientIp::ENV_DISABLED) + + enabled = if disabled.nil? + false + else + Datadog.logger.warn { "#{Tracing::Configuration::Ext::ClientIp::ENV_DISABLED} environment variable is deprecated, found set to #{disabled}, use #{Tracing::Configuration::Ext::ClientIp::ENV_ENABLED}=#{!disabled}" } + + !disabled + end + + # ENABLED env var takes precedence over deprecated DISABLED + env_to_bool(Tracing::Configuration::Ext::ClientIp::ENV_ENABLED, enabled) + end o.lazy end diff --git a/lib/datadog/tracing/configuration/ext.rb b/lib/datadog/tracing/configuration/ext.rb index fb8b86fe6de..6c7ed920af9 100644 --- a/lib/datadog/tracing/configuration/ext.rb +++ b/lib/datadog/tracing/configuration/ext.rb @@ -54,7 +54,8 @@ module Transport # @public_api module ClientIp - ENV_DISABLED = 'DD_TRACE_CLIENT_IP_HEADER_DISABLED'.freeze + ENV_ENABLED = 'DD_TRACE_CLIENT_IP_HEADER_ENABLED'.freeze + ENV_DISABLED = 'DD_TRACE_CLIENT_IP_HEADER_DISABLED'.freeze # TODO: deprecated, remove later ENV_HEADER_NAME = 'DD_TRACE_CLIENT_IP_HEADER'.freeze end end