From 1f432daa14984510e9a1c2391b80e797d8291504 Mon Sep 17 00:00:00 2001 From: Frederik Erbs Spang Thomsen Date: Mon, 16 Sep 2024 15:41:23 +0200 Subject: [PATCH 01/10] Add childspan for Sidekiq Queue instrumentation --- .../sidekiq/sentry_context_middleware.rb | 29 +++++++++++++++---- .../sidekiq/sentry_context_middleware_spec.rb | 1 + sentry-sidekiq/spec/spec_helper.rb | 3 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb b/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb index e43acb653..728fd9d67 100644 --- a/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb +++ b/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb @@ -8,7 +8,7 @@ class SentryContextServerMiddleware OP_NAME = "queue.sidekiq" SPAN_ORIGIN = "auto.queue.sidekiq" - def call(_worker, job, queue) + def call(worker, job, queue) return yield unless Sentry.initialized? context_filter = Sentry::Sidekiq::ContextFilter.new(job) @@ -26,8 +26,18 @@ def call(_worker, job, queue) scope.set_span(transaction) if transaction begin - yield - rescue + Sentry.with_child_span(op: "queue.process", description: "Process #{worker.class.name}") do |span| + # Set span data + if span + span.set_data("messaging.message.id", job["jid"]) + span.set_data("messaging.destination.name", queue) + span.set_data("messaging.message.receive.latency", ((Time.now.to_f - job["enqueued_at"]) * 1000).to_i) + span.set_data("messaging.message.retry.count", job["retry_count"] || 0) + end + + yield + end + rescue => ex finish_transaction(transaction, 500) raise end @@ -63,13 +73,22 @@ def finish_transaction(transaction, status) end class SentryContextClientMiddleware - def call(_worker_class, job, _queue, _redis_pool) + def call(worker_class, job, queue, _redis_pool) return yield unless Sentry.initialized? user = Sentry.get_current_scope.user job["sentry_user"] = user unless user.empty? job["trace_propagation_headers"] ||= Sentry.get_trace_propagation_headers - yield + + Sentry.with_child_span(op: "queue.publish", description: "Enqueue #{worker_class}") do |span| + # Set span data + if span + span.set_data("messaging.message.id", job["jid"]) + span.set_data("messaging.destination.name", queue) + end + + yield + end end end end 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 de5e9416f..b90799e49 100644 --- a/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb +++ b/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb @@ -73,6 +73,7 @@ execute_worker(processor, HappyWorker, trace_propagation_headers: trace_propagation_headers) expect(transport.events.count).to eq(1) + transaction = transport.events[0] expect(transaction).not_to be_nil expect(transaction.contexts.dig(:trace, :trace_id)).to eq(parent_transaction.trace_id) diff --git a/sentry-sidekiq/spec/spec_helper.rb b/sentry-sidekiq/spec/spec_helper.rb index 5e1e6a6e9..7a5e5dca1 100644 --- a/sentry-sidekiq/spec/spec_helper.rb +++ b/sentry-sidekiq/spec/spec_helper.rb @@ -229,13 +229,12 @@ def sidekiq_config(opts) def execute_worker(processor, klass, **options) klass_options = klass.sidekiq_options_hash || {} - # for Ruby < 2.6 klass_options.each do |k, v| options[k.to_sym] = v end - msg = Sidekiq.dump_json(jid: "123123", class: klass, args: [], **options) + msg = Sidekiq.dump_json(created_at: Time.now.to_f, jid: "123123", class: klass, args: [], **options) work = Sidekiq::BasicFetch::UnitOfWork.new('queue:default', msg) process_work(processor, work) end From 1db7b373f3d482b1ad4941fd6667d8fbeade1c80 Mon Sep 17 00:00:00 2001 From: Frederik Erbs Spang Thomsen Date: Thu, 17 Oct 2024 13:53:22 +0200 Subject: [PATCH 02/10] Add basic specs --- .../sidekiq/sentry_context_middleware_spec.rb | 34 +++++++++++++++++++ sentry-sidekiq/spec/spec_helper.rb | 4 ++- 2 files changed, 37 insertions(+), 1 deletion(-) 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 b90799e49..fcdedd2d8 100644 --- a/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb +++ b/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb @@ -65,6 +65,27 @@ expect(transaction.contexts.dig(:trace, :origin)).to eq('auto.queue.sidekiq') end + it "adds a queue.process spans" do + execute_worker(processor, HappyWorker) + execute_worker(processor, HappyWorker, jid: '123456') + + expect(transport.events.count).to eq(2) + + transaction = transport.events[0] + expect(transaction).not_to be_nil + expect(transaction.spans.count).to eq(1) + expect(transaction.spans[0][:data]['messaging.message.id']).to eq('123123') # Default defined in #execute_worker + expect(transaction.spans[0][:data]['messaging.destination.name']).to eq('default') + expect(transaction.spans[0][:data]['messaging.message.retry.count']).to eq(0) + + transaction = transport.events[1] + expect(transaction).not_to be_nil + expect(transaction.spans.count).to eq(1) + expect(transaction.spans[0][:data]['messaging.message.id']).to eq('123456') # Explicitly set above. + expect(transaction.spans[0][:data]['messaging.destination.name']).to eq('default') + expect(transaction.spans[0][:data]['messaging.message.retry.count']).to eq(0) + end + context "with trace_propagation_headers" do let(:parent_transaction) { Sentry.start_transaction(op: "sidekiq") } @@ -157,5 +178,18 @@ expect(second_headers["sentry-trace"]).to eq(transaction.to_sentry_trace) expect(second_headers["baggage"]).to eq(transaction.to_baggage) end + + it "has a queue.publish span" do + message_id = client.push('queue' => 'default', 'class' => HappyWorker, 'args' => []) + + transaction.finish + + expect(transport.events.count).to eq(1) + event = transport.events.last + expect(event.spans.count).to eq(1) + expect(event.spans[0][:op]).to eq("queue.publish") + expect(event.spans[0][:data]['messaging.message.id']).to eq(message_id) + expect(event.spans[0][:data]['messaging.destination.name']).to eq('default') + end end end diff --git a/sentry-sidekiq/spec/spec_helper.rb b/sentry-sidekiq/spec/spec_helper.rb index 7a5e5dca1..0db973fb7 100644 --- a/sentry-sidekiq/spec/spec_helper.rb +++ b/sentry-sidekiq/spec/spec_helper.rb @@ -234,7 +234,9 @@ def execute_worker(processor, klass, **options) options[k.to_sym] = v end - msg = Sidekiq.dump_json(created_at: Time.now.to_f, jid: "123123", class: klass, args: [], **options) + jid = options.delete(:jid) || "123123" + + msg = Sidekiq.dump_json(created_at: Time.now.to_f, enqueued_at: Time.now.to_f, jid: jid, class: klass, args: [], **options) work = Sidekiq::BasicFetch::UnitOfWork.new('queue:default', msg) process_work(processor, work) end From d0e1c327b33f78767318734a3b754f8550a1bd8d Mon Sep 17 00:00:00 2001 From: Frederik Erbs Spang Thomsen Date: Mon, 21 Oct 2024 22:50:15 +0200 Subject: [PATCH 03/10] Remove unneeded exception alloc --- sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb b/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb index 728fd9d67..e7a7afdd3 100644 --- a/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb +++ b/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb @@ -37,7 +37,7 @@ def call(worker, job, queue) yield end - rescue => ex + rescue finish_transaction(transaction, 500) raise end From 4770b3d9c453438ce4d2c4b72f4c6926b1c14537 Mon Sep 17 00:00:00 2001 From: Frederik Erbs Spang Thomsen Date: Mon, 21 Oct 2024 22:51:14 +0200 Subject: [PATCH 04/10] Add CHANGELOG entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a11809b02..0c25e7cb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ ### Features - Add `include_sentry_event` matcher for RSpec [#2424](https://github.com/getsentry/sentry-ruby/pull/2424) -- Add support for Sentry Cache instrumentation, when using Rails.cache [#2380](https://github.com/getsentry/sentry-ruby/pull/2380) +- Add support for Sentry Cache instrumentation, when using Rails.cache ([#2380](https://github.com/getsentry/sentry-ruby/pull/2380)) (MemoryStore and FileStore require Rails 8.0+) +- Add support for Queue Instrumentation for Sidekiq. [#2403](https://github.com/getsentry/sentry-ruby/pull/2403) Note: MemoryStore and FileStore require Rails 8.0+ From 930627ed963d967088453113f2e2e14b98a26ce8 Mon Sep 17 00:00:00 2001 From: Frederik Erbs Spang Thomsen Date: Tue, 22 Oct 2024 10:31:26 +0200 Subject: [PATCH 05/10] Set root op instead of nested spans --- .../sidekiq/sentry_context_middleware.rb | 24 +++++++++---------- .../sidekiq/sentry_context_middleware_spec.rb | 16 ++++++------- sentry-sidekiq/spec/sentry/sidekiq_spec.rb | 2 +- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb b/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb index e7a7afdd3..740b2082b 100644 --- a/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb +++ b/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb @@ -5,7 +5,7 @@ module Sentry module Sidekiq class SentryContextServerMiddleware - OP_NAME = "queue.sidekiq" + OP_NAME = "queue.process" SPAN_ORIGIN = "auto.queue.sidekiq" def call(worker, job, queue) @@ -23,20 +23,18 @@ def call(worker, job, queue) scope.set_contexts(sidekiq: job.merge("queue" => queue)) scope.set_transaction_name(context_filter.transaction_name, source: :task) transaction = start_transaction(scope, job["trace_propagation_headers"]) - scope.set_span(transaction) if transaction + + if transaction + scope.set_span(transaction) + + transaction.set_data("messaging.message.id", job["jid"]) + transaction.set_data("messaging.destination.name", queue) + transaction.set_data("messaging.message.receive.latency", ((Time.now.to_f - job["enqueued_at"]) * 1000).to_i) + transaction.set_data("messaging.message.retry.count", job["retry_count"] || 0) + end begin - Sentry.with_child_span(op: "queue.process", description: "Process #{worker.class.name}") do |span| - # Set span data - if span - span.set_data("messaging.message.id", job["jid"]) - span.set_data("messaging.destination.name", queue) - span.set_data("messaging.message.receive.latency", ((Time.now.to_f - job["enqueued_at"]) * 1000).to_i) - span.set_data("messaging.message.retry.count", job["retry_count"] || 0) - end - - yield - end + yield rescue finish_transaction(transaction, 500) raise 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 fcdedd2d8..ffb24e443 100644 --- a/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb +++ b/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb @@ -73,17 +73,17 @@ transaction = transport.events[0] expect(transaction).not_to be_nil - expect(transaction.spans.count).to eq(1) - expect(transaction.spans[0][:data]['messaging.message.id']).to eq('123123') # Default defined in #execute_worker - expect(transaction.spans[0][:data]['messaging.destination.name']).to eq('default') - expect(transaction.spans[0][:data]['messaging.message.retry.count']).to eq(0) + expect(transaction.spans.count).to eq(0) + expect(transaction.contexts[:trace][:data]['messaging.message.id']).to eq('123123') # Default defined in #execute_worker + expect(transaction.contexts[:trace][:data]['messaging.destination.name']).to eq('default') + expect(transaction.contexts[:trace][:data]['messaging.message.retry.count']).to eq(0) transaction = transport.events[1] expect(transaction).not_to be_nil - expect(transaction.spans.count).to eq(1) - expect(transaction.spans[0][:data]['messaging.message.id']).to eq('123456') # Explicitly set above. - expect(transaction.spans[0][:data]['messaging.destination.name']).to eq('default') - expect(transaction.spans[0][:data]['messaging.message.retry.count']).to eq(0) + expect(transaction.spans.count).to eq(0) + expect(transaction.contexts[:trace][:data]['messaging.message.id']).to eq('123456') # Explicitly set above. + expect(transaction.contexts[:trace][:data]['messaging.destination.name']).to eq('default') + expect(transaction.contexts[:trace][:data]['messaging.message.retry.count']).to eq(0) end context "with trace_propagation_headers" do diff --git a/sentry-sidekiq/spec/sentry/sidekiq_spec.rb b/sentry-sidekiq/spec/sentry/sidekiq_spec.rb index 64fdec5c1..4c788c9ce 100644 --- a/sentry-sidekiq/spec/sentry/sidekiq_spec.rb +++ b/sentry-sidekiq/spec/sentry/sidekiq_spec.rb @@ -223,7 +223,7 @@ def retry_last_failed_job expect(transaction.contexts.dig(:trace, :trace_id)).to be_a(String) expect(transaction.contexts.dig(:trace, :span_id)).to be_a(String) expect(transaction.contexts.dig(:trace, :status)).to eq("ok") - expect(transaction.contexts.dig(:trace, :op)).to eq("queue.sidekiq") + expect(transaction.contexts.dig(:trace, :op)).to eq("queue.process") end it "records transaction with exception" do From ee20ff54764b7b3331fa7aa8c8f85f9d7e95e67f Mon Sep 17 00:00:00 2001 From: Frederik Erbs Spang Thomsen Date: Sun, 27 Oct 2024 13:49:22 +0100 Subject: [PATCH 06/10] Adjust feedback --- sentry-sidekiq/Gemfile | 2 ++ .../sidekiq/sentry_context_middleware.rb | 28 +++++++++------ .../sidekiq/sentry_context_middleware_spec.rb | 34 +++++++++++-------- sentry-sidekiq/spec/spec_helper.rb | 3 ++ 4 files changed, 42 insertions(+), 25 deletions(-) diff --git a/sentry-sidekiq/Gemfile b/sentry-sidekiq/Gemfile index c860cb206..8448e3b77 100644 --- a/sentry-sidekiq/Gemfile +++ b/sentry-sidekiq/Gemfile @@ -25,4 +25,6 @@ end gem "rails", "> 5.0.0" +gem "timecop" + eval_gemfile File.expand_path("../Gemfile", __dir__) diff --git a/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb b/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb index 740b2082b..690f26ade 100644 --- a/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb +++ b/sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb @@ -4,7 +4,20 @@ module Sentry module Sidekiq + module Helpers + def set_span_data(span, id:, queue:, latency: nil, retry_count: nil) + if span + span.set_data("messaging.message.id", id) + span.set_data("messaging.destination.name", queue) + span.set_data("messaging.message.receive.latency", latency) if latency + span.set_data("messaging.message.retry.count", retry_count) if retry_count + end + end + end + class SentryContextServerMiddleware + include Sentry::Sidekiq::Helpers + OP_NAME = "queue.process" SPAN_ORIGIN = "auto.queue.sidekiq" @@ -27,10 +40,7 @@ def call(worker, job, queue) if transaction scope.set_span(transaction) - transaction.set_data("messaging.message.id", job["jid"]) - transaction.set_data("messaging.destination.name", queue) - transaction.set_data("messaging.message.receive.latency", ((Time.now.to_f - job["enqueued_at"]) * 1000).to_i) - transaction.set_data("messaging.message.retry.count", job["retry_count"] || 0) + set_span_data(transaction, id: job["jid"], queue: queue, latency: ((Time.now.to_f - job["enqueued_at"]) * 1000).to_i, retry_count: job["retry_count"] || 0) end begin @@ -71,6 +81,8 @@ def finish_transaction(transaction, status) end class SentryContextClientMiddleware + include Sentry::Sidekiq::Helpers + def call(worker_class, job, queue, _redis_pool) return yield unless Sentry.initialized? @@ -78,12 +90,8 @@ def call(worker_class, job, queue, _redis_pool) job["sentry_user"] = user unless user.empty? job["trace_propagation_headers"] ||= Sentry.get_trace_propagation_headers - Sentry.with_child_span(op: "queue.publish", description: "Enqueue #{worker_class}") do |span| - # Set span data - if span - span.set_data("messaging.message.id", job["jid"]) - span.set_data("messaging.destination.name", queue) - end + Sentry.with_child_span(op: "queue.publish", description: worker_class.to_s) do |span| + set_span_data(span, id: job["jid"], queue: queue) yield end 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 ffb24e443..276bfc4e3 100644 --- a/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb +++ b/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "spec_helper" +require "timecop" RSpec.shared_context "sidekiq", shared_context: :metadata do let(:user) { { "id" => rand(10_000) } } @@ -66,24 +67,27 @@ end it "adds a queue.process spans" do - execute_worker(processor, HappyWorker) - execute_worker(processor, HappyWorker, jid: '123456') + Timecop.freeze do + execute_worker(processor, HappyWorker) + execute_worker(processor, HappyWorker, jid: '123456', timecop_delay: Time.now + 1.day) - expect(transport.events.count).to eq(2) + expect(transport.events.count).to eq(2) - transaction = transport.events[0] - expect(transaction).not_to be_nil - expect(transaction.spans.count).to eq(0) - expect(transaction.contexts[:trace][:data]['messaging.message.id']).to eq('123123') # Default defined in #execute_worker - expect(transaction.contexts[:trace][:data]['messaging.destination.name']).to eq('default') - expect(transaction.contexts[:trace][:data]['messaging.message.retry.count']).to eq(0) + transaction = transport.events[0] + expect(transaction).not_to be_nil + expect(transaction.spans.count).to eq(0) + expect(transaction.contexts[:trace][:data]['messaging.message.id']).to eq('123123') # Default defined in #execute_worker + expect(transaction.contexts[:trace][:data]['messaging.destination.name']).to eq('default') + expect(transaction.contexts[:trace][:data]['messaging.message.retry.count']).to eq(0) + expect(transaction.contexts[:trace][:data]['messaging.message.receive.latency']).to eq(0) - transaction = transport.events[1] - expect(transaction).not_to be_nil - expect(transaction.spans.count).to eq(0) - expect(transaction.contexts[:trace][:data]['messaging.message.id']).to eq('123456') # Explicitly set above. - expect(transaction.contexts[:trace][:data]['messaging.destination.name']).to eq('default') - expect(transaction.contexts[:trace][:data]['messaging.message.retry.count']).to eq(0) + transaction = transport.events[1] + expect(transaction).not_to be_nil + expect(transaction.spans.count).to eq(0) + expect(transaction.contexts[:trace][:data]['messaging.message.id']).to eq('123456') # Explicitly set above. + expect(transaction.contexts[:trace][:data]['messaging.destination.name']).to eq('default') + expect(transaction.contexts[:trace][:data]['messaging.message.receive.latency']).to eq(1.day.to_i * 1000) + end end context "with trace_propagation_headers" do diff --git a/sentry-sidekiq/spec/spec_helper.rb b/sentry-sidekiq/spec/spec_helper.rb index 0db973fb7..1cbc2a60d 100644 --- a/sentry-sidekiq/spec/spec_helper.rb +++ b/sentry-sidekiq/spec/spec_helper.rb @@ -237,8 +237,11 @@ def execute_worker(processor, klass, **options) jid = options.delete(:jid) || "123123" msg = Sidekiq.dump_json(created_at: Time.now.to_f, enqueued_at: Time.now.to_f, jid: jid, class: klass, args: [], **options) + Timecop.freeze(options[:timecop_delay]) if options[:timecop_delay] work = Sidekiq::BasicFetch::UnitOfWork.new('queue:default', msg) process_work(processor, work) +ensure + Timecop.return if options[:timecop_delay] end def process_work(processor, work) From 09429a9eeb79a1b492505bfde07618b9885fb1f9 Mon Sep 17 00:00:00 2001 From: Frederik Erbs Spang Thomsen Date: Mon, 28 Oct 2024 09:05:18 +0100 Subject: [PATCH 07/10] Remove timecop_delay from options hash --- CHANGELOG.md | 2 +- sentry-sidekiq/spec/spec_helper.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c25e7cb0..7d2360ffd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### Features - Add `include_sentry_event` matcher for RSpec [#2424](https://github.com/getsentry/sentry-ruby/pull/2424) -- Add support for Sentry Cache instrumentation, when using Rails.cache ([#2380](https://github.com/getsentry/sentry-ruby/pull/2380)) (MemoryStore and FileStore require Rails 8.0+) +- Add support for Sentry Cache instrumentation, when using Rails.cache ([#2380](https://github.com/getsentry/sentry-ruby/pull/2380)) - Add support for Queue Instrumentation for Sidekiq. [#2403](https://github.com/getsentry/sentry-ruby/pull/2403) Note: MemoryStore and FileStore require Rails 8.0+ diff --git a/sentry-sidekiq/spec/spec_helper.rb b/sentry-sidekiq/spec/spec_helper.rb index 1cbc2a60d..e712a6a0f 100644 --- a/sentry-sidekiq/spec/spec_helper.rb +++ b/sentry-sidekiq/spec/spec_helper.rb @@ -235,13 +235,14 @@ def execute_worker(processor, klass, **options) end jid = options.delete(:jid) || "123123" + timecop_delay = options.delete(:timecop_delay) msg = Sidekiq.dump_json(created_at: Time.now.to_f, enqueued_at: Time.now.to_f, jid: jid, class: klass, args: [], **options) - Timecop.freeze(options[:timecop_delay]) if options[:timecop_delay] + Timecop.freeze(timecop_delay) if timecop_delay work = Sidekiq::BasicFetch::UnitOfWork.new('queue:default', msg) process_work(processor, work) ensure - Timecop.return if options[:timecop_delay] + Timecop.return if timecop_delay end def process_work(processor, work) From 265307a28cc2b774ffefcffbab63bf1a1e76d2d3 Mon Sep 17 00:00:00 2001 From: Frederik Erbs Spang Thomsen Date: Mon, 28 Oct 2024 10:56:48 +0100 Subject: [PATCH 08/10] Fix 1 day --- .../spec/sentry/sidekiq/sentry_context_middleware_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 276bfc4e3..032bca0ba 100644 --- a/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb +++ b/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb @@ -69,7 +69,7 @@ it "adds a queue.process spans" do Timecop.freeze do execute_worker(processor, HappyWorker) - execute_worker(processor, HappyWorker, jid: '123456', timecop_delay: Time.now + 1.day) + execute_worker(processor, HappyWorker, jid: '123456', timecop_delay: Time.now + 1.days) expect(transport.events.count).to eq(2) @@ -86,7 +86,7 @@ expect(transaction.spans.count).to eq(0) expect(transaction.contexts[:trace][:data]['messaging.message.id']).to eq('123456') # Explicitly set above. expect(transaction.contexts[:trace][:data]['messaging.destination.name']).to eq('default') - expect(transaction.contexts[:trace][:data]['messaging.message.receive.latency']).to eq(1.day.to_i * 1000) + expect(transaction.contexts[:trace][:data]['messaging.message.receive.latency']).to eq(1.days.to_i * 1000) end end From ea1fa45b3026365220a37c9dd9a707465186bc27 Mon Sep 17 00:00:00 2001 From: Frederik Erbs Spang Thomsen Date: Mon, 28 Oct 2024 23:31:58 +0100 Subject: [PATCH 09/10] Fix 1.day --- .../spec/sentry/sidekiq/sentry_context_middleware_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 032bca0ba..276bfc4e3 100644 --- a/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb +++ b/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb @@ -69,7 +69,7 @@ it "adds a queue.process spans" do Timecop.freeze do execute_worker(processor, HappyWorker) - execute_worker(processor, HappyWorker, jid: '123456', timecop_delay: Time.now + 1.days) + execute_worker(processor, HappyWorker, jid: '123456', timecop_delay: Time.now + 1.day) expect(transport.events.count).to eq(2) @@ -86,7 +86,7 @@ expect(transaction.spans.count).to eq(0) expect(transaction.contexts[:trace][:data]['messaging.message.id']).to eq('123456') # Explicitly set above. expect(transaction.contexts[:trace][:data]['messaging.destination.name']).to eq('default') - expect(transaction.contexts[:trace][:data]['messaging.message.receive.latency']).to eq(1.days.to_i * 1000) + expect(transaction.contexts[:trace][:data]['messaging.message.receive.latency']).to eq(1.day.to_i * 1000) end end From 5e000c67e1f4bc508d0edde0e56306f3dd833966 Mon Sep 17 00:00:00 2001 From: Frederik Erbs Spang Thomsen Date: Mon, 28 Oct 2024 23:36:55 +0100 Subject: [PATCH 10/10] Dont use .day helper --- .../spec/sentry/sidekiq/sentry_context_middleware_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 276bfc4e3..ea930ee4e 100644 --- a/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb +++ b/sentry-sidekiq/spec/sentry/sidekiq/sentry_context_middleware_spec.rb @@ -69,7 +69,7 @@ it "adds a queue.process spans" do Timecop.freeze do execute_worker(processor, HappyWorker) - execute_worker(processor, HappyWorker, jid: '123456', timecop_delay: Time.now + 1.day) + execute_worker(processor, HappyWorker, jid: '123456', timecop_delay: Time.now + 86400) expect(transport.events.count).to eq(2) @@ -86,7 +86,7 @@ expect(transaction.spans.count).to eq(0) expect(transaction.contexts[:trace][:data]['messaging.message.id']).to eq('123456') # Explicitly set above. expect(transaction.contexts[:trace][:data]['messaging.destination.name']).to eq('default') - expect(transaction.contexts[:trace][:data]['messaging.message.receive.latency']).to eq(1.day.to_i * 1000) + expect(transaction.contexts[:trace][:data]['messaging.message.receive.latency']).to eq(86400000) end end