diff --git a/contrib/ruby_event_store-outbox/CHANGELOG.md b/contrib/ruby_event_store-outbox/CHANGELOG.md index 4beeeb3f4c..50ecaa6171 100644 --- a/contrib/ruby_event_store-outbox/CHANGELOG.md +++ b/contrib/ruby_event_store-outbox/CHANGELOG.md @@ -1,3 +1,7 @@ +### unreleased + +* change the timestamp reported in `enqueued_at` to Sidekiq when pushing jobs from the current time to the record created at timestamp (so that the latency reported in Sidekiq includes the time a job has spent in outbox) + ### 0.0.28 2024-04-12 * Fix issues that prevent res_outbox CLI from processing diff --git a/contrib/ruby_event_store-outbox/lib/ruby_event_store/outbox/sidekiq_processor.rb b/contrib/ruby_event_store-outbox/lib/ruby_event_store/outbox/sidekiq_processor.rb index 8a1e6c454c..870065f3c8 100644 --- a/contrib/ruby_event_store-outbox/lib/ruby_event_store/outbox/sidekiq_processor.rb +++ b/contrib/ruby_event_store-outbox/lib/ruby_event_store/outbox/sidekiq_processor.rb @@ -17,7 +17,7 @@ def process(record, now) queue = parsed_record["queue"] raise InvalidPayload.new("Missing queue") if queue.nil? || queue.empty? - payload = JSON.generate(parsed_record.merge({ "enqueued_at" => now.to_f })) + payload = JSON.generate(parsed_record.merge({ "enqueued_at" => record.created_at.to_f })) redis.call("LPUSH", "queue:#{queue}", payload) diff --git a/contrib/ruby_event_store-outbox/spec/consumer_spec.rb b/contrib/ruby_event_store-outbox/spec/consumer_spec.rb index b5722ad79d..b151e27573 100644 --- a/contrib/ruby_event_store-outbox/spec/consumer_spec.rb +++ b/contrib/ruby_event_store-outbox/spec/consumer_spec.rb @@ -48,7 +48,7 @@ module Outbox expect(redis.call("LLEN", "queue:default")).to eq(1) payload_in_redis = JSON.parse(redis.call("LINDEX", "queue:default", 0)) expect(payload_in_redis).to include(JSON.parse(record.payload)) - expect(payload_in_redis["enqueued_at"]).to eq(clock.tick(1).to_f) + expect(payload_in_redis["enqueued_at"]).to eq(record.created_at.to_f) expect(record.enqueued_at).to eq(clock.tick(1)) expect(result).to eq(true) expect(logger_output.string).to include("Sent 1 messages from outbox table")