Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove client_ip disabled env #3404

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading