@@ -1044,10 +1044,11 @@ def step_3
10441044 end
10451045
10461046 context 'for instrumentation' do
1047- let ( :instrumentation_class ) do
1048- Class . new do
1049- def self . trace ( name )
1050- puts "Trace #{ name } "
1047+ let ( :instrumentation_wrapper ) do
1048+ Class . new ( Opera ::Operation ::Instrumentation ::Base ) do
1049+
1050+ def self . instrument ( operation , name :, level :)
1051+ puts "Trace #{ name } with level #{ level } "
10511052 yield
10521053 end
10531054 end
@@ -1083,42 +1084,25 @@ def step_5
10831084 end
10841085 end
10851086
1086- context 'for operation level' do
1087- before do
1088- Operation ::Config . configure do |config |
1089- config . instrumentation_class = instrumentation_class
1090- config . instrumentation_method = :trace
1091- end
1092- end
1093-
1094- it 'evaluates all steps' do
1095- expect ( subject . executions ) . to match_array ( %i[ step_1 step_2 step_3 step_4 step_5 ] )
1096- end
1097-
1098- it 'calls instrumentation with correct params' do
1099- expect ( instrumentation_class ) . to receive ( :trace ) . with ( 'Opera::FakeName' ) . and_call_original
1100- subject
1087+ before do
1088+ Operation ::Config . configure do |config |
1089+ config . instrumentation_class = instrumentation_wrapper
11011090 end
11021091 end
11031092
1104- context 'for step level' do
1105- before do
1106- Operation ::Config . configure do |config |
1107- config . instrumentation_class = instrumentation_class
1108- config . instrumentation_method = :trace
1109- config . instrumentation_options = { level : :step }
1110- end
1111- end
1112-
1113- it 'evaluates all steps' do
1114- expect ( subject . executions ) . to match_array ( %i[ step_1 step_2 step_3 step_4 step_5 ] )
1115- end
1093+ it 'evaluates all steps' do
1094+ expect ( subject . executions ) . to match_array ( %i[ step_1 step_2 step_3 step_4 step_5 ] )
1095+ end
11161096
1117- it 'calls instrumentation with correct params' do
1118- expect ( instrumentation_class ) . to receive ( :trace ) . exactly ( 6 ) . times . and_call_original
1097+ it 'calls instrumentation with correct params' do
1098+ expect ( instrumentation_wrapper ) . to receive ( :instrument ) . with ( anything , name : 'Opera::FakeName' , level : :operation ) . once . and_call_original
1099+ expect ( instrumentation_wrapper ) . to receive ( :instrument ) . with ( anything , name : '#step_1' , level : :step ) . once . and_call_original
1100+ expect ( instrumentation_wrapper ) . to receive ( :instrument ) . with ( anything , name : '#step_2' , level : :step ) . once . and_call_original
1101+ expect ( instrumentation_wrapper ) . to receive ( :instrument ) . with ( anything , name : '#step_3' , level : :step ) . once . and_call_original
1102+ expect ( instrumentation_wrapper ) . to receive ( :instrument ) . with ( anything , name : '#step_4' , level : :step ) . once . and_call_original
1103+ expect ( instrumentation_wrapper ) . to receive ( :instrument ) . with ( anything , name : '#step_5' , level : :step ) . once
11191104
1120- subject
1121- end
1105+ subject
11221106 end
11231107 end
11241108
0 commit comments