From 2b3949c6f2c8947460fc7ce7fd74aa7bf2f7fa25 Mon Sep 17 00:00:00 2001 From: fallwith Date: Fri, 30 Aug 2024 11:59:00 -0700 Subject: [PATCH 1/2] add test for Sidekiq's perform_inline add a test that confirms that `perform_inline` produces a segment --- .../suites/sidekiq/sidekiq_instrumentation_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb b/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb index 60d7179dd6..68e2ebd274 100644 --- a/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +++ b/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb @@ -53,4 +53,16 @@ def test_captures_sidekiq_internal_errors assert_equal 1, noticed.size assert_equal exception, noticed.first end + + # Sidekiq::Job::Setter#perform_inline is expected to light up all registered + # client and server middleware, and the lighting up of NR's server middleware + # will produce a segment + def test_works_with_perform_inline + in_transaction do |txn| + NRDeadEndJob.perform_inline + segments = txn.segments.select { |s| s.name.eql?('Nested/OtherTransaction/SidekiqJob/NRDeadEndJob/perform') } + + assert_equal 1, segments.size, "Expected to find a single Sidekiq job segment, found #{segments.size}" + end + end end From 9eea9df735f158d800f5a126ddf348eb933a9373 Mon Sep 17 00:00:00 2001 From: fallwith Date: Fri, 30 Aug 2024 12:30:55 -0700 Subject: [PATCH 2/2] Sidekiq inline test: use Sidekiq v7+ restrict the perform_inline test to Sidkiq 7+ --- .../suites/sidekiq/sidekiq_instrumentation_test.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb b/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb index 68e2ebd274..9d75ffbf0f 100644 --- a/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +++ b/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb @@ -58,6 +58,11 @@ def test_captures_sidekiq_internal_errors # client and server middleware, and the lighting up of NR's server middleware # will produce a segment def test_works_with_perform_inline + # Sidekiq version 6.4.2 ends up invoking String#constantize, which is only + # delivered by ActiveSupport, which this test suite doesn't currently + # include. + skip 'This test requires Sidekiq v7+' unless Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('7.0.0') + in_transaction do |txn| NRDeadEndJob.perform_inline segments = txn.segments.select { |s| s.name.eql?('Nested/OtherTransaction/SidekiqJob/NRDeadEndJob/perform') }