Skip to content

Commit

Permalink
Remove configuring tracing.client_ip.enabled with ENV['DD_TRACE_CLIEN…
Browse files Browse the repository at this point in the history
…T_IP_HEADER_DISABLED']
  • Loading branch information
TonyCTHsu committed Jan 25, 2024
1 parent b9c8ffb commit be32fc1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
1 change: 0 additions & 1 deletion lib/datadog/tracing/configuration/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ module Transport
# @public_api
module ClientIp
ENV_ENABLED = 'DD_TRACE_CLIENT_IP_ENABLED'
ENV_DISABLED = 'DD_TRACE_CLIENT_IP_HEADER_DISABLED' # TODO: deprecated, remove later
ENV_HEADER_NAME = 'DD_TRACE_CLIENT_IP_HEADER'
end
end
Expand Down
20 changes: 2 additions & 18 deletions lib/datadog/tracing/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,30 +383,14 @@ def self.extended(base)
# 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 `DD_TRACE_CLIENT_IP_ENABLED` environment variable, otherwise `false`.
# @return [Boolean]
option :enabled do |o|
o.type :bool
o.default do
disabled = Core::Environment::VariableHelpers.env_to_bool(Tracing::Configuration::Ext::ClientIp::ENV_DISABLED)

enabled = if disabled.nil?
false
else
Datadog::Core.log_deprecation do
"#{Tracing::Configuration::Ext::ClientIp::ENV_DISABLED} environment variable is deprecated, use #{Tracing::Configuration::Ext::ClientIp::ENV_ENABLED} instead."
end

!disabled
end

# ENABLED env var takes precedence over deprecated DISABLED
Core::Environment::VariableHelpers.env_to_bool(Tracing::Configuration::Ext::ClientIp::ENV_ENABLED, enabled)
end
o.env Tracing::Configuration::Ext::ClientIp::ENV_ENABLED
o.default false
end

# An optional name of a custom header to resolve the client IP from.
Expand Down
26 changes: 26 additions & 0 deletions spec/datadog/tracing/configuration/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -824,5 +824,31 @@ def propagation_inject_style
.to(true)
end
end

describe '#client_ip.enabled' do
context 'default' do
it do
expect(settings.tracing.client_ip.enabled).to eq(false)
end
end

{
'true' => true,
'1' => true,
'false' => false
}.each do |env, value|
context "when ENV['DD_TRACE_CLIENT_IP_ENABLED'] is '#{env}'" do
around do |example|
ClimateControl.modify('DD_TRACE_CLIENT_IP_ENABLED' => env) do
example.run
end
end

it do
expect(settings.tracing.client_ip.enabled).to eq(value)
end
end
end
end
end
end

0 comments on commit be32fc1

Please sign in to comment.