Skip to content

Commit a2b71e8

Browse files
committed
Improve deprecated config impl
1 parent 29f377e commit a2b71e8

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
3939
MINIMUM_VERSION = Gem::Version.new('2.0.0')
4040

4141
install do |config|
42-
resolve_config(config) unless config[:suppress_internal_instrumentation].nil?
42+
resolve_config(config)
4343
require_dependencies
4444
patch_telemetry_plugin if telemetry_plugin?
4545
add_plugins(Seahorse::Client::Base, *loaded_service_clients)
@@ -54,8 +54,8 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
5454
end
5555

5656
option :inject_messaging_context, default: false, validate: :boolean
57+
option :suppress_internal_instrumentation, default: false, validate: :boolean
5758
option :enable_internal_instrumentation, default: false, validate: :boolean
58-
option :suppress_internal_instrumentation, default: nil, validate: :boolean
5959

6060
def gem_version
6161
if Gem.loaded_specs['aws-sdk']
@@ -70,10 +70,13 @@ def gem_version
7070
private
7171

7272
def resolve_config(config)
73+
return unless config[:suppress_internal_instrumentation]
74+
75+
config[:enable_internal_instrumentation] = false
7376
OpenTelemetry.logger.warn(
74-
'suppress_internal_instrumentation is deprecated, please use enable_internal_instrumentation instead'
77+
'Instrumentation AwsSdk configuration option suppress_internal_instrumentation has been deprecated,' \
78+
'use enable_internal_instrumentation option instead'
7579
)
76-
config[:enable_internal_instrumentation] = !config[:suppress_internal_instrumentation]
7780
end
7881

7982
def require_dependencies

instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,10 @@
7171
instrumentation.install
7272
_(instrumentation.config[:inject_messaging_context]).must_equal(false)
7373
_(instrumentation.config[:enable_internal_instrumentation]).must_equal(false)
74-
assert_nil(instrumentation.config[:suppress_internal_instrumentation])
74+
_(instrumentation.config[:suppress_internal_instrumentation]).must_equal(false)
7575
end
7676

7777
it 'honors deprecated config, :suppress_internal_instrumentation' do
78-
instrumentation.instance_variable_set(:@installed, false)
79-
instrumentation.install(suppress_internal_instrumentation: false)
80-
_(instrumentation.config[:enable_internal_instrumentation]).must_equal(true)
81-
8278
instrumentation.instance_variable_set(:@installed, false)
8379
instrumentation.install(suppress_internal_instrumentation: true)
8480
_(instrumentation.config[:enable_internal_instrumentation]).must_equal(false)

0 commit comments

Comments
 (0)