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

Add more 2.x deprecation warnings #3647

Open
wants to merge 2 commits into
base: 1.x-stable
Choose a base branch
from
Open
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
22 changes: 20 additions & 2 deletions lib/datadog/core/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions spec/datadog/core/configuration/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading