From 9cc99ca7ed214cd77853815a6df4b5b4846ab292 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Thu, 5 Oct 2023 11:16:13 +0100 Subject: [PATCH] Fix sentry-sidekiq's build failure --- sentry-sidekiq/Gemfile | 12 +++++++++--- .../sentry/sidekiq/sentry_context_middleware_spec.rb | 12 ++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sentry-sidekiq/Gemfile b/sentry-sidekiq/Gemfile index 692fae02d..b2bc2e8a8 100644 --- a/sentry-sidekiq/Gemfile +++ b/sentry-sidekiq/Gemfile @@ -17,9 +17,16 @@ gem "loofah", "2.20.0" if RUBY_VERSION.to_f < 2.5 sidekiq_version = ENV["SIDEKIQ_VERSION"] sidekiq_version = "6.0" if sidekiq_version.nil? +sidekiq_version = Gem::Version.new(sidekiq_version) -gem "sidekiq", "~> #{sidekiq_version}" -gem "rails" +if sidekiq_version >= Gem::Version.new("7.0") + # This is for a unreleased fix for sidekiq 7 + # https://github.com/sidekiq/sidekiq/commit/b7236f814ccb61d3b1e6fc5251ed3d3ac7428eb3 + gem "sidekiq", github: "sidekiq/sidekiq" +else + gem "sidekiq", "~> #{sidekiq_version}" +end +gem "rails", "> 5.0.0", "< 7.1.0" if RUBY_VERSION.to_f >= 2.6 gem "debug", github: "ruby/debug", platform: :ruby @@ -27,4 +34,3 @@ if RUBY_VERSION.to_f >= 2.6 end gem "pry" - diff --git a/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb b/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb index 4a8542291..f7c1a21a3 100644 --- a/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb +++ b/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb @@ -22,7 +22,7 @@ execute_worker(processor, SadWorker) expect(transport.events.count).to eq(1) - event = transport.events.first + event = transport.events[0] expect(event.user).to eq(user) end @@ -36,7 +36,7 @@ execute_worker(processor, HappyWorker) expect(transport.events.count).to eq(1) - transaction = transport.events.first + transaction = transport.events[0] expect(transaction).not_to be_nil expect(transaction.user).to eq(user) end @@ -45,7 +45,7 @@ execute_worker(processor, SadWorker) expect(transport.events.count).to eq(2) - transaction = transport.events.first + transaction = transport.events[0] expect(transaction.user).to eq(user) event = transport.events.last expect(event.user).to eq(user) @@ -65,7 +65,7 @@ execute_worker(processor, HappyWorker, trace_propagation_headers: trace_propagation_headers) expect(transport.events.count).to eq(1) - transaction = transport.events.first + transaction = transport.events[0] expect(transaction).not_to be_nil expect(transaction.contexts.dig(:trace, :trace_id)).to eq(parent_transaction.trace_id) end @@ -140,11 +140,11 @@ q = queue.to_a expect(q.size).to be(2) - first_headers = q.first["trace_propagation_headers"] + first_headers = q[0]["trace_propagation_headers"] expect(first_headers["sentry-trace"]).to eq(transaction.to_sentry_trace) expect(first_headers["baggage"]).to eq(transaction.to_baggage) - second_headers = q.second["trace_propagation_headers"] + second_headers = q[1]["trace_propagation_headers"] expect(second_headers["sentry-trace"]).to eq(transaction.to_sentry_trace) expect(second_headers["baggage"]).to eq(transaction.to_baggage) end