Skip to content

Commit

Permalink
fix(sidekiq): rename 'send' operation to 'publish'
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-kazmierczak committed Sep 5, 2023
1 parent 54e73b8 commit e0af35a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def call(_worker_class, job, _queue, _redis_pool)
attributes[SemanticConventions::Trace::PEER_SERVICE] = instrumentation_config[:peer_service] if instrumentation_config[:peer_service]

span_name = case instrumentation_config[:span_naming]
when :job_class then "#{job['wrapped']&.to_s || job['class']} send"
else "#{job['queue']} send"
when :job_class then "#{job['wrapped']&.to_s || job['class']} publish"
else "#{job['queue']} publish"
end

tracer.in_span(span_name, attributes: attributes, kind: :producer) do |span|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

_(exporter.finished_spans.size).must_equal 1

_(enqueue_span.name).must_equal 'default send'
_(enqueue_span.name).must_equal 'default publish'
_(enqueue_span.kind).must_equal :producer
_(enqueue_span.parent_span_id).must_equal OpenTelemetry::Trace::INVALID_SPAN_ID
_(enqueue_span.attributes['messaging.system']).must_equal 'sidekiq'
Expand All @@ -49,7 +49,7 @@

it 'traces when enqueued with Active Job' do
SimpleJobWithActiveJob.perform_later(1, 2)
_(enqueue_span.name).must_equal('default send')
_(enqueue_span.name).must_equal('default publish')
_(enqueue_span.attributes['messaging.system']).must_equal('sidekiq')
_(enqueue_span.attributes['messaging.sidekiq.job_class']).must_equal('SimpleJobWithActiveJob')
_(enqueue_span.attributes['messaging.destination']).must_equal('default')
Expand All @@ -62,12 +62,12 @@
it 'uses the job class name for the span name' do
SimpleJob.perform_async

_(enqueue_span.name).must_equal('SimpleJob send')
_(enqueue_span.name).must_equal('SimpleJob publish')
end

it 'uses the job class name when enqueued with Active Job' do
SimpleJobWithActiveJob.perform_later(1, 2)
_(enqueue_span.name).must_equal('SimpleJobWithActiveJob send')
_(enqueue_span.name).must_equal('SimpleJobWithActiveJob publish')
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@

# root job that enqueues another job
_(root_span.parent_span_id).must_equal OpenTelemetry::Trace::INVALID_SPAN_ID
_(root_span.name).must_equal 'default send'
_(root_span.name).must_equal 'default publish'
_(root_span.kind).must_equal :producer

# process span is linked to the root enqueuing job
Expand All @@ -133,7 +133,7 @@

# enquene span is child to the parent process job
child_span2 = spans.find { |s| s.parent_span_id == child_span1.span_id }
_(child_span2.name).must_equal 'default send'
_(child_span2.name).must_equal 'default publish'
_(child_span2.kind).must_equal :producer

# last process job is linked back to the process job that enqueued it
Expand Down Expand Up @@ -182,15 +182,15 @@
_(exporter.finished_spans.size).must_equal 4

_(root_span.parent_span_id).must_equal OpenTelemetry::Trace::INVALID_SPAN_ID
_(root_span.name).must_equal 'default send'
_(root_span.name).must_equal 'default publish'
_(root_span.kind).must_equal :producer

child_span1 = spans.find { |s| s.parent_span_id == root_span.span_id }
_(child_span1.name).must_equal 'default process'
_(child_span1.kind).must_equal :consumer

child_span2 = spans.find { |s| s.parent_span_id == child_span1.span_id }
_(child_span2.name).must_equal 'default send'
_(child_span2.name).must_equal 'default publish'
_(child_span2.kind).must_equal :producer

child_span3 = spans.find { |s| s.parent_span_id == child_span2.span_id }
Expand Down

0 comments on commit e0af35a

Please sign in to comment.