Skip to content

Commit 8f1430e

Browse files
committed
Added: Deprecation for service when non-string.
1 parent aea7bc9 commit 8f1430e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/datadog/core/configuration/settings.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,16 @@ def initialize(*_)
578578
# @return [String]
579579
option :service do |o|
580580
# DEV-2.0: Remove this conversion for symbol.
581-
o.setter { |v| v.to_s if v }
581+
o.setter do |v|
582+
unless v.nil? || v.is_a?(String)
583+
Datadog::Core.log_deprecation do
584+
"Use of non-strings for 'service' configuration is deprecated. " \
585+
'Use a string instead.'
586+
end
587+
end
588+
589+
v.to_s if v
590+
end
582591

583592
# NOTE: service also gets set as a side effect of tags. See the WORKAROUND note in #initialize for details.
584593
o.env Core::Environment::Ext::ENV_SERVICE

spec/datadog/core/configuration/settings_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,9 +1041,8 @@
10411041
context 'when given a symbol' do
10421042
let(:service) { :symbol }
10431043

1044-
before { set_service }
1045-
1046-
it { expect(settings.service).to eq('symbol') }
1044+
it { expect { set_service }.to log_deprecation }
1045+
it { expect { set_service }.to change { settings.service }.to('symbol') }
10471046
end
10481047

10491048
context 'when given `nil`' do

0 commit comments

Comments
 (0)