Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use record created_at as enqueued_at timestamp when pushing a job to Sidekiq #1789

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contrib/ruby_event_store-outbox/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion contrib/ruby_event_store-outbox/spec/consumer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down