-
Notifications
You must be signed in to change notification settings - Fork 226
fix: Sidekiq spans crashing when enqueued by Exq #1796
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
a0314a8
38c1812
040c291
ed95854
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,31 @@ | |
| _(job_span.attributes['messaging.operation']).must_equal 'process' | ||
| end | ||
|
|
||
| it 'traces when enqueued through another system' do | ||
|
||
| payload = { 'queue' => 'default', 'args' => [], 'class' => SimpleJob, 'enqueued_at' => Time.current, 'jid' => '4' } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't enqueued_at be removed here too?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exq supplies this one, but not
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO, it's not about Exq. It's about what any custom library could do. If it's possible to enqueue a job and have it processed by sidekiq without an `enqueued_at, then we should handle it. |
||
| Sidekiq::Client.new.send(:raw_push, [payload]) | ||
| Sidekiq::Worker.drain_all | ||
|
|
||
| _(job_span.name).must_equal 'default process' | ||
| _(job_span.kind).must_equal :consumer | ||
| _(job_span.attributes['messaging.system']).must_equal 'sidekiq' | ||
| _(job_span.attributes['messaging.sidekiq.job_class']).must_equal 'SimpleJob' | ||
| _(job_span.attributes['messaging.message_id']).must_equal '4' | ||
| _(job_span.attributes['messaging.destination']).must_equal 'default' | ||
| _(job_span.attributes['messaging.destination_kind']).must_equal 'queue' | ||
| _(job_span.attributes['messaging.operation']).must_equal 'process' | ||
| _(job_span.attributes['peer.service']).must_be_nil | ||
| _(job_span.events.size).must_equal(2) | ||
|
|
||
| created_event = job_span.events[0] | ||
| _(created_event.name).must_equal('created_at') | ||
| _(created_event.timestamp.digits.count).must_equal(19) | ||
|
|
||
| enqueued_event = job_span.events[1] | ||
| _(enqueued_event.name).must_equal('enqueued_at') | ||
| _(enqueued_event.timestamp.digits.count).must_equal(19) | ||
| end | ||
|
|
||
| it 'defaults to using links to the enqueing span but does not continue the trace' do | ||
| SimpleJob.perform_async | ||
| SimpleJob.drain | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this end up loosing meaning? Would it not be better to omit the span events in these cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably! I'll admit I'm not an opentelemetry expert; just trying to fix the crash. 🙂
Would it be more advisable to let
time_from_timestamphandle/returnniland skip theadd_eventin those cases?I think letting the
created_atdefault toenqueued_atwhen not specified can still be useful, but maybe not so much the0default (which I only selected since Sidekiq's API does that).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, If the value is not set, we shouldn't have any event. Not provide misleading data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xathien think then that it's best to check if the values are present and only add the events if that's the case. I don't think the timestamp helper should tolerate nil values at this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me! I've updated the change accordingly.