From da351f9edf4329d2287ff0ff4ba2ead6b55a164b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ka=C5=BAmierczak?= Date: Thu, 7 Sep 2023 04:22:52 +0200 Subject: [PATCH] fix!(instrumentation): Align messaging instrumentation operation names (#648) * fix!(active_job): rename 'send' operation to 'publish' * fix!(aws_sdk): rename 'send' operation to 'publish' * fix!(bunny): rename 'send' operation to 'publish' * fix!(delayed_job): rename 'send' operation to 'publish' * fix!(queue): rename 'send' operation to 'publish' * fix!(racecar): rename 'send' operation to 'publish' * fix!(rdkafka): rename 'send' operation to 'publish' * fix!(ruby_kafka): rename 'send' operation to 'publish' * fix!(sidekiq): rename 'send' operation to 'publish' --------- Co-authored-by: Sam <370182+plantfansam@users.noreply.github.com> --- .../patches/active_job_callbacks.rb | 2 +- .../patches/active_job_callbacks_test.rb | 68 +++++++++---------- .../instrumentation/aws_sdk/handler.rb | 2 +- .../opentelemetry/instrumentation_test.rb | 2 +- .../instrumentation/bunny/patch_helpers.rb | 2 +- .../bunny/patches/channel_test.rb | 26 +++---- .../bunny/patches/consumer_test.rb | 10 +-- .../bunny/patches/queue_test.rb | 6 +- .../delayed_job/plugins/tracer_plugin.rb | 4 +- .../delayed_job/plugins/tracer_plugin_test.rb | 6 +- .../instrumentation/que/patches/que_job.rb | 6 +- .../opentelemetry/instrumentation/que_test.rb | 58 ++++++++-------- .../racecar/patches/consumer.rb | 2 +- .../instrumentation/racecar_test.rb | 60 ++++++++-------- .../rdkafka/patches/producer.rb | 2 +- .../rdkafka/patches/consumer_test.rb | 22 +++--- .../rdkafka/patches/producer_test.rb | 2 +- .../resque/patches/resque_module.rb | 4 +- .../resque/patches/resque_test.rb | 8 +-- .../ruby_kafka/patches/client.rb | 2 +- .../ruby_kafka/patches/producer.rb | 2 +- .../ruby-kafka/patches/client_test.rb | 8 +-- .../ruby-kafka/patches/consumer_test.rb | 22 +++--- .../ruby-kafka/patches/producer_test.rb | 18 ++--- .../middlewares/client/tracer_middleware.rb | 4 +- .../client/tracer_middleware_test.rb | 8 +-- .../server/tracer_middleware_test.rb | 8 +-- 27 files changed, 182 insertions(+), 182 deletions(-) diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb index f2a242310..c3f612599 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb @@ -14,7 +14,7 @@ def self.prepended(base) base.class_eval do around_enqueue do |job, block| span_kind = job.class.queue_adapter_name == 'inline' ? :client : :producer - span_name = "#{otel_config[:span_naming] == :job_class ? job.class : job.queue_name} send" + span_name = "#{otel_config[:span_naming] == :job_class ? job.class : job.queue_name} publish" span_attributes = job_attributes(job) otel_tracer.in_span(span_name, attributes: span_attributes, kind: span_kind) do OpenTelemetry.propagation.inject(job.metadata) diff --git a/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb b/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb index 7a01df947..f2c6f996c 100644 --- a/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb +++ b/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb @@ -16,7 +16,7 @@ let(:config) { { propagation_style: :link, force_flush: false, span_naming: :queue } } let(:exporter) { EXPORTER } let(:spans) { exporter.finished_spans } - let(:send_span) { spans.find { |s| s.name == 'default send' } } + let(:publish_span) { spans.find { |s| s.name == 'default publish' } } let(:process_span) { spans.find { |s| s.name == 'default process' } } before do @@ -41,7 +41,7 @@ it 'traces enqueuing and processing the job' do TestJob.perform_later - _(send_span).wont_be_nil + _(publish_span).wont_be_nil _(process_span).wont_be_nil end end @@ -50,7 +50,7 @@ it 'only traces processing the job' do TestJob.perform_now - _(send_span).must_be_nil + _(publish_span).must_be_nil _(process_span).wont_be_nil _(process_span.attributes['code.namespace']).must_equal('TestJob') _(process_span.attributes['code.function']).must_equal('perform_now') @@ -97,14 +97,14 @@ TestJob.perform_later - _(send_span.kind).must_equal(:client) + _(publish_span.kind).must_equal(:client) _(process_span.kind).must_equal(:server) end it 'sets correct span kinds for all other jobs' do TestJob.perform_later - _(send_span.kind).must_equal(:producer) + _(publish_span.kind).must_equal(:producer) _(process_span.kind).must_equal(:consumer) end end @@ -113,7 +113,7 @@ it 'sets the messaging.operation attribute only when processing the job' do TestJob.perform_later - _(send_span.attributes['messaging.operation']).must_be_nil + _(publish_span.attributes['messaging.operation']).must_be_nil _(process_span.attributes['messaging.operation']).must_equal('process') end @@ -121,7 +121,7 @@ it 'is sets correctly for inline jobs' do TestJob.perform_later - [send_span, process_span].each do |span| + [publish_span, process_span].each do |span| _(span.attributes['net.transport']).must_equal('inproc') end end @@ -129,7 +129,7 @@ it 'is set correctly for async jobs' do TestJob.perform_later - [send_span, process_span].each do |span| + [publish_span, process_span].each do |span| _(span.attributes['net.transport']).must_equal('inproc') end end @@ -139,7 +139,7 @@ it 'is unset for unprioritized jobs' do TestJob.perform_later - [send_span, process_span].each do |span| + [publish_span, process_span].each do |span| _(span.attributes['messaging.active_job.priority']).must_be_nil end end @@ -147,7 +147,7 @@ it 'is set for jobs with a priority' do TestJob.set(priority: 1).perform_later - [send_span, process_span].each do |span| + [publish_span, process_span].each do |span| _(span.attributes['messaging.active_job.priority']).must_equal(1) end end @@ -157,7 +157,7 @@ it 'is unset for jobs that do not specify a wait time' do TestJob.perform_later - [send_span, process_span].each do |span| + [publish_span, process_span].each do |span| _(span.attributes['messaging.active_job.scheduled_at']).must_be_nil end end @@ -166,8 +166,8 @@ job = TestJob.set(wait: 0.second).perform_later # Only the sending span is a 'scheduled' thing - _(send_span.attributes['messaging.active_job.scheduled_at']).must_equal(job.scheduled_at) - assert(send_span.attributes['messaging.active_job.scheduled_at']) + _(publish_span.attributes['messaging.active_job.scheduled_at']).must_equal(job.scheduled_at) + assert(publish_span.attributes['messaging.active_job.scheduled_at']) # The processing span isn't a 'scheduled' thing _(process_span.attributes['messaging.active_job.scheduled_at']).must_be_nil @@ -185,7 +185,7 @@ ActiveJob::Base.queue_adapter = :inline TestJob.perform_later - [send_span, process_span].each do |span| + [publish_span, process_span].each do |span| _(span.attributes['messaging.system']).must_equal('inline') end end @@ -193,7 +193,7 @@ it 'is set correctly for the async adapter' do TestJob.perform_later - [send_span, process_span].each do |span| + [publish_span, process_span].each do |span| _(span.attributes['messaging.system']).must_equal('async') end end @@ -232,7 +232,7 @@ it 'generally sets other attributes as expected' do job = TestJob.perform_later - [send_span, process_span].each do |span| + [publish_span, process_span].each do |span| _(span.attributes['code.namespace']).must_equal('TestJob') _(span.attributes['messaging.destination_kind']).must_equal('queue') _(span.attributes['messaging.system']).must_equal('async') @@ -245,8 +245,8 @@ describe 'when queue - default' do it 'names spans according to the job queue' do TestJob.set(queue: :foo).perform_later - send_span = exporter.finished_spans.find { |s| s.name == 'foo send' } - _(send_span).wont_be_nil + publish_span = exporter.finished_spans.find { |s| s.name == 'foo publish' } + _(publish_span).wont_be_nil process_span = exporter.finished_spans.find { |s| s.name == 'foo process' } _(process_span).wont_be_nil @@ -258,8 +258,8 @@ it 'names span according to the job class' do TestJob.set(queue: :foo).perform_later - send_span = exporter.finished_spans.find { |s| s.name == 'TestJob send' } - _(send_span).wont_be_nil + publish_span = exporter.finished_spans.find { |s| s.name == 'TestJob publish' } + _(publish_span).wont_be_nil process_span = exporter.finished_spans.find { |s| s.name == 'TestJob process' } _(process_span).wont_be_nil @@ -309,11 +309,11 @@ it 'creates span links in separate traces' do TestJob.perform_later - _(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 it 'propagates baggage' do @@ -322,11 +322,11 @@ BaggageJob.perform_later end - _(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) _(process_span.attributes['success']).must_equal(true) end end @@ -339,8 +339,8 @@ _(process_span.total_recorded_links).must_equal(0) - _(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) end it 'propagates baggage' do @@ -350,8 +350,8 @@ end _(process_span.total_recorded_links).must_equal(0) - _(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.attributes['success']).must_equal(true) end end @@ -364,8 +364,8 @@ _(process_span.total_recorded_links).must_equal(0) - _(send_span.trace_id).wont_equal(process_span.trace_id) - _(process_span.parent_span_id).wont_equal(send_span.span_id) + _(publish_span.trace_id).wont_equal(process_span.trace_id) + _(process_span.parent_span_id).wont_equal(publish_span.span_id) end it 'still propagates baggage' do @@ -376,8 +376,8 @@ _(process_span.total_recorded_links).must_equal(0) - _(send_span.trace_id).wont_equal(process_span.trace_id) - _(process_span.parent_span_id).wont_equal(send_span.span_id) + _(publish_span.trace_id).wont_equal(process_span.trace_id) + _(process_span.parent_span_id).wont_equal(publish_span.span_id) _(process_span.attributes['success']).must_equal(true) end end diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/handler.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/handler.rb index 50bad4617..a973adeb5 100644 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/handler.rb +++ b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/handler.rb @@ -95,7 +95,7 @@ def span_kind(client_method) def span_name(context, client_method) case client_method when SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH - "#{MessagingHelper.queue_name(context)} send" + "#{MessagingHelper.queue_name(context)} publish" when SQS_RECEIVE_MESSAGE "#{MessagingHelper.queue_name(context)} receive" else diff --git a/instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb b/instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb index ed07e858c..1917da5e0 100644 --- a/instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb +++ b/instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb @@ -205,7 +205,7 @@ sns_client.publish message: 'msg', phone_number: '123456' _(last_span.attributes['messaging.destination']).must_equal 'phone_number' - _(last_span.name).must_equal 'phone_number send' + _(last_span.name).must_equal 'phone_number publish' end end end diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb index 8e2d0f4e6..4cb67b884 100644 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb +++ b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb @@ -16,7 +16,7 @@ def self.with_send_span(channel, tracer, exchange, routing_key, &block) attributes = basic_attributes(channel, channel.connection, exchange, routing_key) destination = destination_name(exchange, routing_key) - tracer.in_span("#{destination} send", attributes: attributes, kind: :producer, &block) + tracer.in_span("#{destination} publish", attributes: attributes, kind: :producer, &block) end def self.with_process_span(channel, tracer, delivery_info, properties, &block) diff --git a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/channel_test.rb b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/channel_test.rb index f82c72bb1..737483c7e 100644 --- a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/channel_test.rb +++ b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/channel_test.rb @@ -48,17 +48,17 @@ _(spans.size >= 3).must_equal(true) - send_span = spans.find { |span| span.name == "#{topic}.ruby.news send" } - _(send_span).wont_be_nil - _(send_span.kind).must_equal(:producer) - _(send_span.attributes['messaging.system']).must_equal('rabbitmq') - _(send_span.attributes['messaging.destination']).must_equal(topic) - _(send_span.attributes['messaging.destination_kind']).must_equal('topic') - _(send_span.attributes['messaging.protocol']).must_equal('AMQP') - _(send_span.attributes['messaging.protocol_version']).must_equal('0.9.1') - _(send_span.attributes['messaging.rabbitmq.routing_key']).must_equal('ruby.news') - _(send_span.attributes['net.peer.name']).must_equal(host) - _(send_span.attributes['net.peer.port']).must_equal(port.to_i) + publish_span = spans.find { |span| span.name == "#{topic}.ruby.news publish" } + _(publish_span).wont_be_nil + _(publish_span.kind).must_equal(:producer) + _(publish_span.attributes['messaging.system']).must_equal('rabbitmq') + _(publish_span.attributes['messaging.destination']).must_equal(topic) + _(publish_span.attributes['messaging.destination_kind']).must_equal('topic') + _(publish_span.attributes['messaging.protocol']).must_equal('AMQP') + _(publish_span.attributes['messaging.protocol_version']).must_equal('0.9.1') + _(publish_span.attributes['messaging.rabbitmq.routing_key']).must_equal('ruby.news') + _(publish_span.attributes['net.peer.name']).must_equal(host) + _(publish_span.attributes['net.peer.port']).must_equal(port.to_i) receive_span = spans.find { |span| span.name == "#{topic}.ruby.news receive" } _(receive_span).wont_be_nil @@ -78,7 +78,7 @@ _(process_span.trace_id).must_equal(receive_span.trace_id) linked_span_context = process_span.links.first.span_context - _(linked_span_context.trace_id).must_equal(send_span.trace_id) - _(linked_span_context.span_id).must_equal(send_span.span_id) + _(linked_span_context.trace_id).must_equal(publish_span.trace_id) + _(linked_span_context.span_id).must_equal(publish_span.span_id) end end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/consumer_test.rb b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/consumer_test.rb index d6322014e..2d19600bc 100644 --- a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/consumer_test.rb +++ b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/consumer_test.rb @@ -53,9 +53,9 @@ _(spans.size >= 3).must_equal(true) - send_span = spans.find { |span| span.name == "#{topic}.ruby.news send" } - _(send_span).wont_be_nil - _(send_span.kind).must_equal(:producer) + publish_span = spans.find { |span| span.name == "#{topic}.ruby.news publish" } + _(publish_span).wont_be_nil + _(publish_span.kind).must_equal(:producer) receive_span = spans.find { |span| span.name == "#{topic}.ruby.news receive" } _(receive_span).wont_be_nil @@ -68,7 +68,7 @@ _(process_span.trace_id).must_equal(receive_span.trace_id) linked_span_context = process_span.links.first.span_context - _(linked_span_context.trace_id).must_equal(send_span.trace_id) - _(linked_span_context.span_id).must_equal(send_span.span_id) + _(linked_span_context.trace_id).must_equal(publish_span.trace_id) + _(linked_span_context.span_id).must_equal(publish_span.span_id) end end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/queue_test.rb b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/queue_test.rb index c0c90a292..86c2df1ee 100644 --- a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/queue_test.rb +++ b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/queue_test.rb @@ -47,8 +47,8 @@ queue.pop { |_delivery_info, _metadata, _payload| break } - send_span = spans.find { |span| span.name == ".#{queue_name} send" } - _(send_span).wont_be_nil + publish_span = spans.find { |span| span.name == ".#{queue_name} publish" } + _(publish_span).wont_be_nil receive_span = spans.find { |span| span.name == ".#{queue_name} receive" } _(receive_span).wont_be_nil @@ -58,7 +58,7 @@ _(process_span.kind).must_equal(:consumer) linked_span_context = process_span.links.first.span_context - _(linked_span_context.trace_id).must_equal(send_span.trace_id) + _(linked_span_context.trace_id).must_equal(publish_span.trace_id) end it 'traces messages returned' do diff --git a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb index 5d9e49fd8..fccba0641 100644 --- a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb +++ b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb @@ -17,10 +17,10 @@ def instrument_enqueue(job, &block) return block.call(job) unless enabled? attributes = build_attributes(job) - attributes['messaging.operation'] = 'send' + attributes['messaging.operation'] = 'publish' attributes.compact! - tracer.in_span("#{job_queue(job)} send", attributes: attributes, kind: :producer) do |span| + tracer.in_span("#{job_queue(job)} publish", attributes: attributes, kind: :producer) do |span| yield job span.set_attribute('messaging.message_id', job.id.to_s) add_events(span, job) diff --git a/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb b/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb index 17f1f93a7..2f358cefe 100644 --- a/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb +++ b/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb @@ -65,13 +65,13 @@ def job_data _(exporter.finished_spans.size).must_equal 1 _(span).must_be_kind_of OpenTelemetry::SDK::Trace::SpanData - _(span.name).must_equal 'default send' + _(span.name).must_equal 'default publish' _(span.attributes['messaging.system']).must_equal 'delayed_job' _(span.attributes['messaging.destination']).must_equal 'default' _(span.attributes['messaging.destination_kind']).must_equal 'queue' _(span.attributes['messaging.delayed_job.name']).must_equal 'BasicPayload' _(span.attributes['messaging.delayed_job.priority']).must_equal 0 - _(span.attributes['messaging.operation']).must_equal 'send' + _(span.attributes['messaging.operation']).must_equal 'publish' _(span.attributes['messaging.message_id']).must_be_kind_of String _(span.events.size).must_equal 2 @@ -122,7 +122,7 @@ def job_data _(exporter.finished_spans).must_equal [] job_enqueue _(exporter.finished_spans.size).must_equal 1 - _(exporter.finished_spans.first.name).must_equal 'default send' + _(exporter.finished_spans.first.name).must_equal 'default publish' job_run _(exporter.finished_spans.size).must_equal 2 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/racecar/lib/opentelemetry/instrumentation/racecar/patches/consumer.rb b/instrumentation/racecar/lib/opentelemetry/instrumentation/racecar/patches/consumer.rb index f1d46eae8..ba711d575 100644 --- a/instrumentation/racecar/lib/opentelemetry/instrumentation/racecar/patches/consumer.rb +++ b/instrumentation/racecar/lib/opentelemetry/instrumentation/racecar/patches/consumer.rb @@ -19,7 +19,7 @@ def produce(payload, topic:, key: nil, partition: nil, partition_key: nil, heade headers ||= {} - tracer.in_span("#{topic} send", attributes: attributes, kind: :producer) do + tracer.in_span("#{topic} publish", attributes: attributes, kind: :producer) do OpenTelemetry.propagation.inject(headers) super end diff --git a/instrumentation/racecar/test/opentelemetry/instrumentation/racecar_test.rb b/instrumentation/racecar/test/opentelemetry/instrumentation/racecar_test.rb index 66b63d5ed..44be8030b 100644 --- a/instrumentation/racecar/test/opentelemetry/instrumentation/racecar_test.rb +++ b/instrumentation/racecar/test/opentelemetry/instrumentation/racecar_test.rb @@ -40,7 +40,7 @@ def produce(messages) producer.delivery_callback = ->(_) {} producer_messages.map do |msg| - tracer.in_span("#{msg[:topic]} send", kind: :producer) do + tracer.in_span("#{msg[:topic]} publish", kind: :producer) do msg[:headers] ||= {} OpenTelemetry.propagation.inject(msg[:headers]) producer.produce(**msg) @@ -120,9 +120,9 @@ def stop_racecar(thread) it 'traces each message and traces publishing' do process_spans = spans.select { |s| s.name == "#{topic_name} process" } - racecar_send_spans = spans.select { |s| s.name == "ack-#{topic_name} send" } + racecar_publish_spans = spans.select { |s| s.name == "ack-#{topic_name} publish" } - # First pair for send and process spans + # First pair for publish and process spans first_process_span = process_spans[0] _(first_process_span.name).must_equal("#{topic_name} process") _(first_process_span.kind).must_equal(:consumer) @@ -132,20 +132,20 @@ def stop_racecar(thread) first_process_span_link = first_process_span.links[0] linked_span_context = first_process_span_link.span_context - linked_send_span = spans.find { |s| s.span_id == linked_span_context.span_id } - _(linked_send_span.name).must_equal("#{topic_name} send") - _(linked_send_span.trace_id).must_equal(first_process_span.trace_id) - _(linked_send_span.trace_id).must_equal(linked_span_context.trace_id) + linked_publish_span = spans.find { |s| s.span_id == linked_span_context.span_id } + _(linked_publish_span.name).must_equal("#{topic_name} publish") + _(linked_publish_span.trace_id).must_equal(first_process_span.trace_id) + _(linked_publish_span.trace_id).must_equal(linked_span_context.trace_id) # first racecar ack span - first_send_span = racecar_send_spans[0] - _(first_send_span.name).must_equal("ack-#{topic_name} send") - _(first_send_span.kind).must_equal(:producer) - _(first_send_span.instrumentation_library.name).must_equal('OpenTelemetry::Instrumentation::Racecar') - _(first_send_span.parent_span_id).must_equal(first_process_span.span_id) - _(first_send_span.trace_id).must_equal(first_process_span.trace_id) - - # Second pair of send and process spans + first_publish_span = racecar_publish_spans[0] + _(first_publish_span.name).must_equal("ack-#{topic_name} publish") + _(first_publish_span.kind).must_equal(:producer) + _(first_publish_span.instrumentation_library.name).must_equal('OpenTelemetry::Instrumentation::Racecar') + _(first_publish_span.parent_span_id).must_equal(first_process_span.span_id) + _(first_publish_span.trace_id).must_equal(first_process_span.trace_id) + + # Second pair of publish and process spans second_process_span = process_spans[1] _(second_process_span.name).must_equal("#{topic_name} process") _(second_process_span.kind).must_equal(:consumer) @@ -153,18 +153,18 @@ def stop_racecar(thread) second_process_span_link = second_process_span.links[0] linked_span_context = second_process_span_link.span_context - linked_send_span = spans.find { |s| s.span_id == linked_span_context.span_id } - _(linked_send_span.name).must_equal("#{topic_name} send") - _(linked_send_span.trace_id).must_equal(second_process_span.trace_id) - _(linked_send_span.trace_id).must_equal(linked_span_context.trace_id) + linked_publish_span = spans.find { |s| s.span_id == linked_span_context.span_id } + _(linked_publish_span.name).must_equal("#{topic_name} publish") + _(linked_publish_span.trace_id).must_equal(second_process_span.trace_id) + _(linked_publish_span.trace_id).must_equal(linked_span_context.trace_id) # second racecar ack span - second_send_span = racecar_send_spans[1] - _(second_send_span.name).must_equal("ack-#{topic_name} send") - _(second_send_span.kind).must_equal(:producer) - _(second_send_span.instrumentation_library.name).must_equal('OpenTelemetry::Instrumentation::Racecar') - _(second_send_span.parent_span_id).must_equal(second_process_span.span_id) - _(second_send_span.trace_id).must_equal(second_process_span.trace_id) + second_publish_span = racecar_publish_spans[1] + _(second_publish_span.name).must_equal("ack-#{topic_name} publish") + _(second_publish_span.kind).must_equal(:producer) + _(second_publish_span.instrumentation_library.name).must_equal('OpenTelemetry::Instrumentation::Racecar') + _(second_publish_span.parent_span_id).must_equal(second_process_span.span_id) + _(second_publish_span.trace_id).must_equal(second_process_span.trace_id) end describe 'when message keys are encoded differently' do @@ -212,7 +212,7 @@ def stop_racecar(thread) it 'can consume and publish a message' do process_spans = spans.select { |s| s.name == "#{topic_name} process" } - # First pair for send and process spans + # First pair for publish and process spans first_process_span = process_spans[0] _(first_process_span.name).must_equal("#{topic_name} process") _(first_process_span.kind).must_equal(:consumer) @@ -222,10 +222,10 @@ def stop_racecar(thread) first_process_span_link = first_process_span.links[0] linked_span_context = first_process_span_link.span_context - linked_send_span = spans.find { |s| s.span_id == linked_span_context.span_id } - _(linked_send_span.name).must_equal("#{topic_name} send") - _(linked_send_span.trace_id).must_equal(first_process_span.trace_id) - _(linked_send_span.trace_id).must_equal(linked_span_context.trace_id) + linked_publish_span = spans.find { |s| s.span_id == linked_span_context.span_id } + _(linked_publish_span.name).must_equal("#{topic_name} publish") + _(linked_publish_span.trace_id).must_equal(first_process_span.trace_id) + _(linked_publish_span.trace_id).must_equal(linked_span_context.trace_id) event = first_process_span.events.first _(event.name).must_equal('exception') diff --git a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb b/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb index 7b234b70e..3515f9ca5 100644 --- a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb +++ b/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb @@ -19,7 +19,7 @@ def produce(topic:, payload: nil, key: nil, partition: nil, partition_key: nil, headers ||= {} - tracer.in_span("#{topic} send", attributes: attributes, kind: :producer) do + tracer.in_span("#{topic} publish", attributes: attributes, kind: :producer) do OpenTelemetry.propagation.inject(headers) super end diff --git a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb index 3ddcaf2f9..bfd2f9da7 100644 --- a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb +++ b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb @@ -72,7 +72,7 @@ process_spans = spans.select { |s| s.name == "#{topic_name} process" } - # First pair for send and process spans + # First pair for publish and process spans first_process_span = process_spans[0] _(first_process_span.name).must_equal("#{topic_name} process") _(first_process_span.kind).must_equal(:consumer) @@ -82,12 +82,12 @@ first_process_span_link = first_process_span.links[0] linked_span_context = first_process_span_link.span_context - linked_send_span = spans.find { |s| s.span_id == linked_span_context.span_id } - _(linked_send_span.name).must_equal("#{topic_name} send") - _(linked_send_span.trace_id).must_equal(first_process_span.trace_id) - _(linked_send_span.trace_id).must_equal(linked_span_context.trace_id) + linked_publish_span = spans.find { |s| s.span_id == linked_span_context.span_id } + _(linked_publish_span.name).must_equal("#{topic_name} publish") + _(linked_publish_span.trace_id).must_equal(first_process_span.trace_id) + _(linked_publish_span.trace_id).must_equal(linked_span_context.trace_id) - # Second pair of send and process spans + # Second pair of publish and process spans second_process_span = process_spans[1] _(second_process_span.name).must_equal("#{topic_name} process") _(second_process_span.kind).must_equal(:consumer) @@ -95,10 +95,10 @@ second_process_span_link = second_process_span.links[0] linked_span_context = second_process_span_link.span_context - linked_send_span = spans.find { |s| s.span_id == linked_span_context.span_id } - _(linked_send_span.name).must_equal("#{topic_name} send") - _(linked_send_span.trace_id).must_equal(second_process_span.trace_id) - _(linked_send_span.trace_id).must_equal(linked_span_context.trace_id) + linked_publish_span = spans.find { |s| s.span_id == linked_span_context.span_id } + _(linked_publish_span.name).must_equal("#{topic_name} publish") + _(linked_publish_span.trace_id).must_equal(second_process_span.trace_id) + _(linked_publish_span.trace_id).must_equal(linked_span_context.trace_id) event = second_process_span.events.first _(event.name).must_equal('exception') @@ -148,7 +148,7 @@ _(spans.size).must_equal(4) process_spans = spans.select { |s| s.name == "#{topic_name} process" } - # First pair for send and process spans + # First pair for publish and process spans first_process_span = process_spans[0] _(first_process_span.attributes).wont_include('messaging.kafka.message_key') diff --git a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb index 983d8b157..06e40de58 100644 --- a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb +++ b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb @@ -48,7 +48,7 @@ delivery_handles.each(&:wait) - _(spans.first.name).must_equal("#{topic_name} send") + _(spans.first.name).must_equal("#{topic_name} publish") _(spans.first.kind).must_equal(:producer) _(spans.first.attributes['messaging.system']).must_equal('kafka') 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 diff --git a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/client.rb b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/client.rb index 09996bd76..1e5a5d4da 100644 --- a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/client.rb +++ b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/client.rb @@ -24,7 +24,7 @@ def deliver_message(value, topic:, key: nil, headers: {}, partition: nil, partit attributes['messaging.kafka.partition'] = partition if partition - tracer.in_span("#{topic} send", attributes: attributes, kind: :producer) do + tracer.in_span("#{topic} publish", attributes: attributes, kind: :producer) do OpenTelemetry.propagation.inject(headers) super end diff --git a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb index 5b1948546..8d7880be0 100644 --- a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb +++ b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb @@ -22,7 +22,7 @@ def produce(value, topic:, key: nil, headers: {}, partition: nil, partition_key: # Thread's context, so the next two lines preserve the correct Thread-local context. ctx = OpenTelemetry.propagation.extract(headers) OpenTelemetry::Context.with_current(ctx) do - tracer.in_span("#{topic} send", attributes: attributes, kind: :producer) do + tracer.in_span("#{topic} publish", attributes: attributes, kind: :producer) do OpenTelemetry.propagation.inject(headers) super end diff --git a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/client_test.rb b/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/client_test.rb index b6b97982e..a5c6a3e80 100644 --- a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/client_test.rb +++ b/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/client_test.rb @@ -40,7 +40,7 @@ kafka.each_message(topic: topic) { |_msg| break } # rubocop:disable Lint/UnreachableLoop _(spans.size).must_equal(2) - _(spans[0].name).must_equal("#{topic} send") + _(spans[0].name).must_equal("#{topic} publish") _(spans[0].kind).must_equal(:producer) _(spans[1].name).must_equal("#{topic} process") @@ -57,9 +57,9 @@ break if counter >= 2 end - send_spans = spans.select { |s| s.name == "#{topic} send" } - _(send_spans[0].attributes).wont_include('messaging.kafka.message_key') - _(send_spans[1].attributes['messaging.kafka.message_key']).must_equal('foobarbaz') + publish_spans = spans.select { |s| s.name == "#{topic} publish" } + _(publish_spans[0].attributes).wont_include('messaging.kafka.message_key') + _(publish_spans[1].attributes['messaging.kafka.message_key']).must_equal('foobarbaz') process_spans = spans.select { |s| s.name == "#{topic} process" } _(process_spans[0].attributes).wont_include('messaging.kafka.message_key') diff --git a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/consumer_test.rb b/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/consumer_test.rb index 5c9937a26..2a175612b 100644 --- a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/consumer_test.rb +++ b/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/consumer_test.rb @@ -58,7 +58,7 @@ process_spans = spans.select { |s| s.name == "#{topic} process" } - # First pair for send and process spans + # First pair for publish and process spans first_process_span = process_spans[0] _(first_process_span.name).must_equal("#{topic} process") _(first_process_span.kind).must_equal(:consumer) @@ -68,12 +68,12 @@ first_process_span_link = first_process_span.links[0] linked_span_context = first_process_span_link.span_context - linked_send_span = spans.find { |s| s.span_id == linked_span_context.span_id } - _(linked_send_span.name).must_equal("#{topic} send") - _(linked_send_span.trace_id).must_equal(first_process_span.trace_id) - _(linked_send_span.trace_id).must_equal(linked_span_context.trace_id) + linked_publish_span = spans.find { |s| s.span_id == linked_span_context.span_id } + _(linked_publish_span.name).must_equal("#{topic} publish") + _(linked_publish_span.trace_id).must_equal(first_process_span.trace_id) + _(linked_publish_span.trace_id).must_equal(linked_span_context.trace_id) - # Second pair of send and process spans + # Second pair of publish and process spans second_process_span = process_spans[1] _(second_process_span.name).must_equal("#{topic} process") _(second_process_span.kind).must_equal(:consumer) @@ -81,10 +81,10 @@ second_process_span_link = second_process_span.links[0] linked_span_context = second_process_span_link.span_context - linked_send_span = spans.find { |s| s.span_id == linked_span_context.span_id } - _(linked_send_span.name).must_equal("#{topic} send") - _(linked_send_span.trace_id).must_equal(second_process_span.trace_id) - _(linked_send_span.trace_id).must_equal(linked_span_context.trace_id) + linked_publish_span = spans.find { |s| s.span_id == linked_span_context.span_id } + _(linked_publish_span.name).must_equal("#{topic} publish") + _(linked_publish_span.trace_id).must_equal(second_process_span.trace_id) + _(linked_publish_span.trace_id).must_equal(linked_span_context.trace_id) event = second_process_span.events.first _(event.name).must_equal('exception') @@ -106,7 +106,7 @@ process_spans = spans.select { |s| s.name == "#{topic} process" } - # First pair for send and process spans + # First pair for publish and process spans first_process_span = process_spans[0] _(first_process_span.attributes).wont_include('messaging.kafka.message_key') diff --git a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/producer_test.rb b/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/producer_test.rb index 15c298437..8324e1000 100644 --- a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/producer_test.rb +++ b/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/producer_test.rb @@ -24,8 +24,8 @@ let(:producer) { kafka.producer } let(:consumer) { kafka.consumer(group_id: SecureRandom.uuid, fetcher_max_queue_size: 1) } let(:async_producer) { kafka.async_producer(delivery_threshold: 1000) } - let(:send_span) { EXPORTER.finished_spans.find { |sp| sp.name == "#{topic} send" } } - let(:async_send_span) { EXPORTER.finished_spans.find { |sp| sp.name == "#{async_topic} send" } } + let(:publish_span) { EXPORTER.finished_spans.find { |sp| sp.name == "#{topic} publish" } } + let(:async_publish_span) { EXPORTER.finished_spans.find { |sp| sp.name == "#{async_topic} publish" } } before do kafka.create_topic(topic) @@ -54,7 +54,7 @@ producer.produce('hello', topic: topic) producer.deliver_messages - _(spans.first.name).must_equal("#{topic} send") + _(spans.first.name).must_equal("#{topic} publish") _(spans.first.kind).must_equal(:producer) _(spans.first.attributes['messaging.system']).must_equal('kafka') @@ -68,7 +68,7 @@ # Wait for the async calls to produce spans wait_for(error_message: 'Max wait time exceeded for async producer') { EXPORTER.finished_spans.size.positive? } - _(spans.first.name).must_equal("#{async_topic} send") + _(spans.first.name).must_equal("#{async_topic} publish") _(spans.first.kind).must_equal(:producer) _(spans.first.attributes['messaging.system']).must_equal('kafka') @@ -83,8 +83,8 @@ producer.deliver_messages end - _(send_span.hex_parent_span_id).must_equal(span_id) - _(send_span.hex_trace_id).must_equal(trace_id) + _(publish_span.hex_parent_span_id).must_equal(span_id) + _(publish_span.hex_trace_id).must_equal(trace_id) end it 'propagates context when tracing async produce calls' do @@ -98,8 +98,8 @@ # Wait for the async calls to produce spans wait_for(error_message: 'Max wait time exceeded for async producer') { EXPORTER.finished_spans.size == 2 } - _(async_send_span.trace_id).must_equal(sp.context.trace_id) - _(async_send_span.parent_span_id).must_equal(sp.context.span_id) + _(async_publish_span.trace_id).must_equal(sp.context.trace_id) + _(async_publish_span.parent_span_id).must_equal(sp.context.span_id) end it 'propagates context for nonrecording spans' do @@ -122,7 +122,7 @@ end sp.finish _(EXPORTER.finished_spans.size).must_equal(2) - _(send_span.hex_parent_span_id).must_equal(sp.context.hex_span_id) + _(publish_span.hex_parent_span_id).must_equal(sp.context.hex_span_id) end end end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb index 02105564b..039390a8f 100644 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb +++ b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb @@ -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| diff --git a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware_test.rb b/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware_test.rb index b76c490c4..a2de3d05d 100644 --- a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware_test.rb +++ b/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware_test.rb @@ -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' @@ -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') @@ -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 diff --git a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware_test.rb b/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware_test.rb index 716ca8373..145d3b743 100644 --- a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware_test.rb +++ b/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware_test.rb @@ -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 @@ -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 @@ -182,7 +182,7 @@ _(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 } @@ -190,7 +190,7 @@ _(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 }