@@ -230,10 +230,10 @@ def target_method
230
230
231
231
let ( :payloads ) { [ ] }
232
232
233
- def do_rc ( expect_hook : true )
233
+ def do_rc ( expect_hook : :hook_method )
234
234
expect ( probe_manager ) . to receive ( :add_probe ) . and_call_original
235
235
if expect_hook
236
- expect ( instrumenter ) . to receive ( :hook_method ) . and_call_original
236
+ expect ( instrumenter ) . to receive ( expect_hook ) . and_call_original
237
237
end
238
238
# Events can be batched, meaning +post+ could be called once or twice
239
239
# depending on how threads are scheduled by the VM.
@@ -370,13 +370,22 @@ def assert_received_and_errored
370
370
context 'line probe' do
371
371
with_code_tracking
372
372
373
- context 'line probe received targeting loaded code not in code tracker' do
374
- let ( :probe_spec ) do
375
- { id : '11' , name : 'bar' , type : 'LOG_PROBE' , where : {
376
- sourceFile : 'instrumentation_integration_test_class.rb' , lines : [ 22 ]
377
- } }
373
+ shared_context 'targeting integration test class via load' do
374
+ before do
375
+ begin
376
+ Object . send ( :remove_const , :InstrumentationIntegrationTestClass )
377
+ rescue
378
+ nil
379
+ end
380
+ load File . join ( File . dirname ( __FILE__ ) , 'instrumentation_integration_test_class.rb' )
381
+
382
+ # We want the probe status to be reported, therefore need to
383
+ # disable exception propagation.
384
+ settings . dynamic_instrumentation . internal . propagate_all_exceptions = false
378
385
end
386
+ end
379
387
388
+ shared_context 'targeting integration test class via require' do
380
389
before do
381
390
begin
382
391
Object . send ( :remove_const , :InstrumentationIntegrationTestClass )
@@ -391,14 +400,46 @@ def assert_received_and_errored
391
400
expect ( $LOADED_FEATURES. detect do |path |
392
401
File . basename ( path ) == 'instrumentation_integration_test_class.rb'
393
402
end ) . to be_truthy
394
- component . code_tracker . clear
395
403
396
404
# We want the probe status to be reported, therefore need to
397
405
# disable exception propagation.
398
406
settings . dynamic_instrumentation . internal . propagate_all_exceptions = false
399
407
end
408
+ end
409
+
410
+ context 'line probe with path containing extra prefix directories' do
411
+ let ( :probe_spec ) do
412
+ { id : '11' , name : 'bar' , type : 'LOG_PROBE' , where : {
413
+ sourceFile : 'junk/prefix/instrumentation_integration_test_class.rb' , lines : [ 22 ]
414
+ } }
415
+ end
416
+
417
+ include_context 'targeting integration test class via load'
400
418
401
419
it 'instruments code and adds probe to installed list' do
420
+ expect_lazy_log ( logger , :debug , /received probe from RC:/ )
421
+
422
+ do_rc ( expect_hook : :hook_line )
423
+ assert_received_and_installed
424
+
425
+ expect ( probe_manager . installed_probes . length ) . to eq 1
426
+ end
427
+ end
428
+
429
+ context 'line probe received targeting loaded code not in code tracker' do
430
+ let ( :probe_spec ) do
431
+ { id : '11' , name : 'bar' , type : 'LOG_PROBE' , where : {
432
+ sourceFile : 'instrumentation_integration_test_class.rb' , lines : [ 22 ]
433
+ } }
434
+ end
435
+
436
+ include_context 'targeting integration test class via require'
437
+
438
+ before do
439
+ component . code_tracker . clear
440
+ end
441
+
442
+ it 'marks RC payload as errored' do
402
443
expect_lazy_log_many ( logger , :debug ,
403
444
/received probe from RC:/ ,
404
445
/error processing probe configuration:.*File matching probe path.*was loaded and is not in code tracker registry/ , )
0 commit comments