diff --git a/lib/datadog/core/configuration/settings.rb b/lib/datadog/core/configuration/settings.rb index d3fc59edd75..7e4315ab19f 100644 --- a/lib/datadog/core/configuration/settings.rb +++ b/lib/datadog/core/configuration/settings.rb @@ -157,7 +157,16 @@ def initialize(*_) # @return [String,nil] option :env do |o| # DEV-2.0: Remove this conversion for symbol. - o.setter { |v| v.to_s if v } + o.setter do |v| + unless v.nil? || v.is_a?(String) + Datadog::Core.log_deprecation(key: :core_configuration_settings_env_non_string) do + "Use of non-strings for 'env' configuration is deprecated. " \ + 'Use a string instead.' + end + end + + v.to_s if v + end # NOTE: env also gets set as a side effect of tags. See the WORKAROUND note in #initialize for details. o.env Core::Environment::Ext::ENV_ENVIRONMENT @@ -569,7 +578,16 @@ def initialize(*_) # @return [String] option :service do |o| # DEV-2.0: Remove this conversion for symbol. - o.setter { |v| v.to_s if v } + o.setter do |v| + unless v.nil? || v.is_a?(String) + Datadog::Core.log_deprecation(key: :core_configuration_settings_service_non_string) do + "Use of non-strings for 'service' configuration is deprecated. " \ + 'Use a string instead.' + end + end + + v.to_s if v + end # NOTE: service also gets set as a side effect of tags. See the WORKAROUND note in #initialize for details. o.env Core::Environment::Ext::ENV_SERVICE diff --git a/spec/datadog/core/configuration/settings_spec.rb b/spec/datadog/core/configuration/settings_spec.rb index 96d9137db02..958ba33d1ac 100644 --- a/spec/datadog/core/configuration/settings_spec.rb +++ b/spec/datadog/core/configuration/settings_spec.rb @@ -230,9 +230,8 @@ context 'when given a symbol' do let(:env) { :symbol } - before { set_env } - - it { expect(settings.env).to eq('symbol') } + it { expect { set_env }.to log_deprecation } + it { expect { set_env }.to change { settings.env }.from(nil).to('symbol') } end context 'when given `nil`' do @@ -1042,9 +1041,8 @@ context 'when given a symbol' do let(:service) { :symbol } - before { set_service } - - it { expect(settings.service).to eq('symbol') } + it { expect { set_service }.to log_deprecation } + it { expect { set_service }.to change { settings.service }.to('symbol') } end context 'when given `nil`' do