Track scheduled vs enqueued metrics #34
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a previously incorrect finding that
Sidekiq::Context.current[:class].present?
would help us differentiate whether or not to categorize a passthrough of a job through the Client middleware as anenqueue
.The more appropriate determining factor is actually the presence of the numeric timestamp typed
at
field that is passed within thejob
parameter for scheduled jobs. The presence ofat
indicates that this job is not being placed on a queue right now, but rather it is being scheduled to be enqueued later at the numeric timestamp value ofat
.This change will prepare the Client Middleware to correctly handle the following two ways a worker can perform:
perform_async
: a job is not scheduled and immediately is enqueued with noat
field.perform_in
: a job is scheduled and passed in with anat
field for when it should hit the middleware an additional time without theat
field to be enqueued.The other types of performs don't hit the Client Middleware at all, as
perform_inline
andnew.perform
cause a job to execute synchronously.Example
job
payload whenperform_in(1.second)
is used by a worker:You can see above that the numeric timestamp value of
at
is the value ofcreated_at
with an additional second added to the timestamp.