From be32fc10965d8287939a22d57c3b67f5284042ee Mon Sep 17 00:00:00 2001 From: Tony Hsu Date: Thu, 25 Jan 2024 21:27:02 +0100 Subject: [PATCH] Remove configuring tracing.client_ip.enabled with ENV['DD_TRACE_CLIENT_IP_HEADER_DISABLED'] --- lib/datadog/tracing/configuration/ext.rb | 1 - lib/datadog/tracing/configuration/settings.rb | 20 ++------------ .../tracing/configuration/settings_spec.rb | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/lib/datadog/tracing/configuration/ext.rb b/lib/datadog/tracing/configuration/ext.rb index afb4a19acf..ad911586bf 100644 --- a/lib/datadog/tracing/configuration/ext.rb +++ b/lib/datadog/tracing/configuration/ext.rb @@ -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 diff --git a/lib/datadog/tracing/configuration/settings.rb b/lib/datadog/tracing/configuration/settings.rb index 83a70d6ee6..4b7e2d6c6f 100644 --- a/lib/datadog/tracing/configuration/settings.rb +++ b/lib/datadog/tracing/configuration/settings.rb @@ -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. diff --git a/spec/datadog/tracing/configuration/settings_spec.rb b/spec/datadog/tracing/configuration/settings_spec.rb index 14167b7789..3c910163dd 100644 --- a/spec/datadog/tracing/configuration/settings_spec.rb +++ b/spec/datadog/tracing/configuration/settings_spec.rb @@ -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