Skip to content

Commit

Permalink
Change client ip env var to ENABLED
Browse files Browse the repository at this point in the history
  • Loading branch information
lloeki committed Oct 26, 2022
1 parent 27a9d2c commit 4c373e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
20 changes: 17 additions & 3 deletions lib/datadog/core/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion lib/datadog/tracing/configuration/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4c373e4

Please sign in to comment.