File tree Expand file tree Collapse file tree 3 files changed +27
-7
lines changed
lib/opentelemetry/instrumentation/aws_sdk Expand file tree Collapse file tree 3 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,8 @@ module AwsSdk
3838 class Instrumentation < OpenTelemetry ::Instrumentation ::Base
3939 MINIMUM_VERSION = Gem ::Version . new ( '2.0.0' )
4040
41- install do |_config |
41+ install do |config |
42+ resolve_config ( config ) unless config [ :suppress_internal_instrumentation ] . nil?
4243 require_dependencies
4344 patch_telemetry_plugin if telemetry_plugin?
4445 add_plugins ( Seahorse ::Client ::Base , *loaded_service_clients )
@@ -54,6 +55,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
5455
5556 option :inject_messaging_context , default : false , validate : :boolean
5657 option :enable_internal_instrumentation , default : false , validate : :boolean
58+ option :suppress_internal_instrumentation , default : nil , validate : :boolean
5759
5860 def gem_version
5961 if Gem . loaded_specs [ 'aws-sdk' ]
@@ -67,6 +69,13 @@ def gem_version
6769
6870 private
6971
72+ def resolve_config ( config )
73+ OpenTelemetry . logger . warn (
74+ 'suppress_internal_instrumentation is deprecated, please use enable_internal_instrumentation instead'
75+ )
76+ config [ :enable_internal_instrumentation ] = !config [ :suppress_internal_instrumentation ]
77+ end
78+
7079 def require_dependencies
7180 require_relative 'handler'
7281 require_relative 'handler_helper'
Original file line number Diff line number Diff line change 6666 end
6767 end
6868
69- describe '#install with default options' do
70- it 'with default options' do
71- _ ( instrumentation . config [ :inject_messaging_context ] ) . must_equal ( false )
72- _ ( instrumentation . config [ :enable_internal_instrumentation ] ) . must_equal ( false )
73- end
69+ it 'with default options' do
70+ instrumentation . instance_variable_set ( :@installed , false )
71+ instrumentation . install
72+ _ ( instrumentation . config [ :inject_messaging_context ] ) . must_equal ( false )
73+ _ ( instrumentation . config [ :enable_internal_instrumentation ] ) . must_equal ( false )
74+ assert_nil ( instrumentation . config [ :suppress_internal_instrumentation ] )
75+ end
76+
77+ 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+
82+ instrumentation . instance_variable_set ( :@installed , false )
83+ instrumentation . install ( suppress_internal_instrumentation : true )
84+ _ ( instrumentation . config [ :enable_internal_instrumentation ] ) . must_equal ( false )
7485 end
7586end
Original file line number Diff line number Diff line change 7070
7171 it 'creates internal spans when enabled' do
7272 skip unless TestHelper . telemetry_plugin? ( service_name )
73- stub_request ( :get , 'https://lambda.us-east-1.amazonaws.com/2015-03-31/functions/ ' )
73+ stub_request ( :get , 'https://lambda.us-east-1.amazonaws.com/2015-03-31/functions' )
7474 client = Aws ::Lambda ::Client . new (
7575 telemetry_provider : otel_provider ,
7676 credentials : Aws ::Credentials . new ( 'akid' , 'secret' ) ,
You can’t perform that action at this time.
0 commit comments