From 61f23aa3f241e41b5cb0f55be7bec93a447206b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ka=C5=BAmierczak?= Date: Tue, 5 Sep 2023 08:22:50 +0200 Subject: [PATCH] fix(queue): rename 'send' operation to 'publish' --- .../instrumentation/que/patches/que_job.rb | 6 +- .../opentelemetry/instrumentation/que_test.rb | 58 +++++++++---------- .../resque/patches/resque_module.rb | 4 +- .../resque/patches/resque_test.rb | 8 +-- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/instrumentation/que/lib/opentelemetry/instrumentation/que/patches/que_job.rb b/instrumentation/que/lib/opentelemetry/instrumentation/que/patches/que_job.rb index 7e89e9f89..5be898984 100644 --- a/instrumentation/que/lib/opentelemetry/instrumentation/que/patches/que_job.rb +++ b/instrumentation/que/lib/opentelemetry/instrumentation/que/patches/que_job.rb @@ -22,7 +22,7 @@ def enqueue(*args, job_options: {}, **arg_opts) tracer = Que::Instrumentation.instance.tracer otel_config = Que::Instrumentation.instance.config - tracer.in_span('send', kind: :producer) do |span| + tracer.in_span('publish', kind: :producer) do |span| # Que doesn't have a good place to store metadata. There are # basically two options: the job payload and the job tags. # @@ -57,7 +57,7 @@ def enqueue(*args, job_options: {}, **arg_opts) job_attrs = job.que_attrs end - span.name = "#{job_attrs[:job_class]} send" + span.name = "#{job_attrs[:job_class]} publish" span.add_attributes(QueJob.job_attributes(job_attrs)) job @@ -73,7 +73,7 @@ def self.job_attributes(job_attrs) attributes = { 'messaging.system' => 'que', 'messaging.destination_kind' => 'queue', - 'messaging.operation' => 'send', + 'messaging.operation' => 'publish', 'messaging.destination' => job_attrs[:queue] || 'default', 'messaging.que.job_class' => job_attrs[:job_class], 'messaging.que.priority' => job_attrs[:priority] || 100 diff --git a/instrumentation/que/test/opentelemetry/instrumentation/que_test.rb b/instrumentation/que/test/opentelemetry/instrumentation/que_test.rb index 5c4c9bfd4..9ec9847c1 100644 --- a/instrumentation/que/test/opentelemetry/instrumentation/que_test.rb +++ b/instrumentation/que/test/opentelemetry/instrumentation/que_test.rb @@ -35,7 +35,7 @@ TestJobAsync.enqueue span = finished_spans.last - _(span.name).must_equal('TestJobAsync send') + _(span.name).must_equal('TestJobAsync publish') end it 'records attributes' do @@ -45,7 +45,7 @@ _(attributes['messaging.system']).must_equal('que') _(attributes['messaging.destination']).must_equal('default') _(attributes['messaging.destination_kind']).must_equal('queue') - _(attributes['messaging.operation']).must_equal('send') + _(attributes['messaging.operation']).must_equal('publish') _(attributes['messaging.message_id']).must_be_instance_of(Integer) _(attributes['messaging.que.job_class']).must_equal('TestJobAsync') _(attributes['messaging.que.priority']).must_equal(100) @@ -117,7 +117,7 @@ TestJobSync.enqueue span1 = finished_spans.last - _(span1.name).must_equal('TestJobSync send') + _(span1.name).must_equal('TestJobSync publish') span2 = finished_spans.first _(span2.name).must_equal('TestJobSync process') @@ -171,14 +171,14 @@ def self.run(first, second); end _(finished_spans.size).must_equal(2) - send_span = finished_spans.first + publish_span = finished_spans.first process_span = finished_spans.last - _(send_span.trace_id).wont_equal(process_span.trace_id) + _(publish_span.trace_id).wont_equal(process_span.trace_id) _(process_span.total_recorded_links).must_equal(1) - _(process_span.links[0].span_context.trace_id).must_equal(send_span.trace_id) - _(process_span.links[0].span_context.span_id).must_equal(send_span.span_id) + _(process_span.links[0].span_context.trace_id).must_equal(publish_span.trace_id) + _(process_span.links[0].span_context.span_id).must_equal(publish_span.span_id) end end @@ -191,11 +191,11 @@ def self.run(first, second); end _(finished_spans.size).must_equal(2) - send_span = finished_spans.first + publish_span = finished_spans.first process_span = finished_spans.last - _(send_span.trace_id).must_equal(process_span.trace_id) - _(process_span.parent_span_id).must_equal(send_span.span_id) + _(publish_span.trace_id).must_equal(process_span.trace_id) + _(process_span.parent_span_id).must_equal(publish_span.span_id) _(process_span.total_recorded_links).must_equal(0) end end @@ -221,11 +221,11 @@ def self.run(first, second); end _(finished_spans.size).must_equal(2) - send_span = finished_spans.first + publish_span = finished_spans.first process_span = finished_spans.last - _(send_span.trace_id).wont_equal(process_span.trace_id) - _(send_span.total_recorded_links).must_equal(0) + _(publish_span.trace_id).wont_equal(process_span.trace_id) + _(publish_span.total_recorded_links).must_equal(0) _(process_span.total_recorded_links).must_equal(0) end end @@ -281,7 +281,7 @@ def self.run(first, second); end end span = finished_spans.last - _(span.name).must_equal('TestJobAsync send') + _(span.name).must_equal('TestJobAsync publish') end it 'links spans together' do @@ -293,14 +293,14 @@ def self.run(first, second); end _(finished_spans.size).must_equal(2) - send_span = finished_spans.first + publish_span = finished_spans.first process_span = finished_spans.last - _(send_span.trace_id).wont_equal(process_span.trace_id) + _(publish_span.trace_id).wont_equal(process_span.trace_id) _(process_span.total_recorded_links).must_equal(1) - _(process_span.links[0].span_context.trace_id).must_equal(send_span.trace_id) - _(process_span.links[0].span_context.span_id).must_equal(send_span.span_id) + _(process_span.links[0].span_context.trace_id).must_equal(publish_span.trace_id) + _(process_span.links[0].span_context.span_id).must_equal(publish_span.span_id) end end @@ -376,7 +376,7 @@ def self.run(first, second); end end span1 = finished_spans.first - _(span1.name).must_equal('TestJobSync send') + _(span1.name).must_equal('TestJobSync publish') span2 = finished_spans.last _(span2.name).must_equal('TestJobSync process') @@ -429,14 +429,14 @@ def self.run(first, second); end _(finished_spans.size).must_equal(2) - send_span = finished_spans.first + publish_span = finished_spans.first process_span = finished_spans.last - _(send_span.trace_id).wont_equal(process_span.trace_id) + _(publish_span.trace_id).wont_equal(process_span.trace_id) _(process_span.total_recorded_links).must_equal(1) - _(process_span.links[0].span_context.trace_id).must_equal(send_span.trace_id) - _(process_span.links[0].span_context.span_id).must_equal(send_span.span_id) + _(process_span.links[0].span_context.trace_id).must_equal(publish_span.trace_id) + _(process_span.links[0].span_context.span_id).must_equal(publish_span.span_id) end end @@ -452,11 +452,11 @@ def self.run(first, second); end _(finished_spans.size).must_equal(2) - send_span = finished_spans.first + publish_span = finished_spans.first process_span = finished_spans.last - _(send_span.trace_id).must_equal(process_span.trace_id) - _(process_span.parent_span_id).must_equal(send_span.span_id) + _(publish_span.trace_id).must_equal(process_span.trace_id) + _(process_span.parent_span_id).must_equal(publish_span.span_id) _(process_span.total_recorded_links).must_equal(0) end end @@ -482,11 +482,11 @@ def self.run(first, second); end _(finished_spans.size).must_equal(2) - send_span = finished_spans.first + publish_span = finished_spans.first process_span = finished_spans.last - _(send_span.trace_id).wont_equal(process_span.trace_id) - _(send_span.total_recorded_links).must_equal(0) + _(publish_span.trace_id).wont_equal(process_span.trace_id) + _(publish_span.total_recorded_links).must_equal(0) _(process_span.total_recorded_links).must_equal(0) end end diff --git a/instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_module.rb b/instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_module.rb index 98d6de033..bde8b8737 100644 --- a/instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_module.rb +++ b/instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_module.rb @@ -35,8 +35,8 @@ def push(queue, item) } span_name = case config[:span_naming] - when :job_class then "#{job_class} send" - else "#{queue} send" + when :job_class then "#{job_class} publish" + else "#{queue} publish" end tracer.in_span(span_name, attributes: attributes, kind: :producer) do diff --git a/instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_test.rb b/instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_test.rb index 951add09b..1b8f7ee1a 100644 --- a/instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_test.rb +++ b/instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_test.rb @@ -26,7 +26,7 @@ it 'traces' do Resque.enqueue(DummyJob) - _(enqueue_span.name).must_equal('super_urgent send') + _(enqueue_span.name).must_equal('super_urgent publish') _(enqueue_span.attributes['messaging.system']).must_equal('resque') _(enqueue_span.attributes['messaging.resque.job_class']).must_equal('DummyJob') _(enqueue_span.attributes['messaging.destination']).must_equal('super_urgent') @@ -35,7 +35,7 @@ it 'traces when enqueued with Active Job' do DummyJobWithActiveJob.perform_later(1, 2) - _(enqueue_span.name).must_equal('super_urgent send') + _(enqueue_span.name).must_equal('super_urgent publish') _(enqueue_span.attributes['messaging.system']).must_equal('resque') _(enqueue_span.attributes['messaging.resque.job_class']).must_equal('DummyJobWithActiveJob') _(enqueue_span.attributes['messaging.destination']).must_equal('super_urgent') @@ -48,12 +48,12 @@ it 'uses the job class name for the span name' do Resque.enqueue(DummyJob) - _(enqueue_span.name).must_equal('DummyJob send') + _(enqueue_span.name).must_equal('DummyJob publish') end it 'uses the job class name when enqueued with Active Job' do DummyJobWithActiveJob.perform_later(1, 2) - _(enqueue_span.name).must_equal('DummyJobWithActiveJob send') + _(enqueue_span.name).must_equal('DummyJobWithActiveJob publish') end end end