Skip to content

Commit da351f9

Browse files
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 <[email protected]>
1 parent b14901e commit da351f9

File tree

27 files changed

+182
-182
lines changed

27 files changed

+182
-182
lines changed

instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def self.prepended(base)
1414
base.class_eval do
1515
around_enqueue do |job, block|
1616
span_kind = job.class.queue_adapter_name == 'inline' ? :client : :producer
17-
span_name = "#{otel_config[:span_naming] == :job_class ? job.class : job.queue_name} send"
17+
span_name = "#{otel_config[:span_naming] == :job_class ? job.class : job.queue_name} publish"
1818
span_attributes = job_attributes(job)
1919
otel_tracer.in_span(span_name, attributes: span_attributes, kind: span_kind) do
2020
OpenTelemetry.propagation.inject(job.metadata)

instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
let(:config) { { propagation_style: :link, force_flush: false, span_naming: :queue } }
1717
let(:exporter) { EXPORTER }
1818
let(:spans) { exporter.finished_spans }
19-
let(:send_span) { spans.find { |s| s.name == 'default send' } }
19+
let(:publish_span) { spans.find { |s| s.name == 'default publish' } }
2020
let(:process_span) { spans.find { |s| s.name == 'default process' } }
2121

2222
before do
@@ -41,7 +41,7 @@
4141
it 'traces enqueuing and processing the job' do
4242
TestJob.perform_later
4343

44-
_(send_span).wont_be_nil
44+
_(publish_span).wont_be_nil
4545
_(process_span).wont_be_nil
4646
end
4747
end
@@ -50,7 +50,7 @@
5050
it 'only traces processing the job' do
5151
TestJob.perform_now
5252

53-
_(send_span).must_be_nil
53+
_(publish_span).must_be_nil
5454
_(process_span).wont_be_nil
5555
_(process_span.attributes['code.namespace']).must_equal('TestJob')
5656
_(process_span.attributes['code.function']).must_equal('perform_now')
@@ -97,14 +97,14 @@
9797

9898
TestJob.perform_later
9999

100-
_(send_span.kind).must_equal(:client)
100+
_(publish_span.kind).must_equal(:client)
101101
_(process_span.kind).must_equal(:server)
102102
end
103103

104104
it 'sets correct span kinds for all other jobs' do
105105
TestJob.perform_later
106106

107-
_(send_span.kind).must_equal(:producer)
107+
_(publish_span.kind).must_equal(:producer)
108108
_(process_span.kind).must_equal(:consumer)
109109
end
110110
end
@@ -113,23 +113,23 @@
113113
it 'sets the messaging.operation attribute only when processing the job' do
114114
TestJob.perform_later
115115

116-
_(send_span.attributes['messaging.operation']).must_be_nil
116+
_(publish_span.attributes['messaging.operation']).must_be_nil
117117
_(process_span.attributes['messaging.operation']).must_equal('process')
118118
end
119119

120120
describe 'net.transport' do
121121
it 'is sets correctly for inline jobs' do
122122
TestJob.perform_later
123123

124-
[send_span, process_span].each do |span|
124+
[publish_span, process_span].each do |span|
125125
_(span.attributes['net.transport']).must_equal('inproc')
126126
end
127127
end
128128

129129
it 'is set correctly for async jobs' do
130130
TestJob.perform_later
131131

132-
[send_span, process_span].each do |span|
132+
[publish_span, process_span].each do |span|
133133
_(span.attributes['net.transport']).must_equal('inproc')
134134
end
135135
end
@@ -139,15 +139,15 @@
139139
it 'is unset for unprioritized jobs' do
140140
TestJob.perform_later
141141

142-
[send_span, process_span].each do |span|
142+
[publish_span, process_span].each do |span|
143143
_(span.attributes['messaging.active_job.priority']).must_be_nil
144144
end
145145
end
146146

147147
it 'is set for jobs with a priority' do
148148
TestJob.set(priority: 1).perform_later
149149

150-
[send_span, process_span].each do |span|
150+
[publish_span, process_span].each do |span|
151151
_(span.attributes['messaging.active_job.priority']).must_equal(1)
152152
end
153153
end
@@ -157,7 +157,7 @@
157157
it 'is unset for jobs that do not specify a wait time' do
158158
TestJob.perform_later
159159

160-
[send_span, process_span].each do |span|
160+
[publish_span, process_span].each do |span|
161161
_(span.attributes['messaging.active_job.scheduled_at']).must_be_nil
162162
end
163163
end
@@ -166,8 +166,8 @@
166166
job = TestJob.set(wait: 0.second).perform_later
167167

168168
# Only the sending span is a 'scheduled' thing
169-
_(send_span.attributes['messaging.active_job.scheduled_at']).must_equal(job.scheduled_at)
170-
assert(send_span.attributes['messaging.active_job.scheduled_at'])
169+
_(publish_span.attributes['messaging.active_job.scheduled_at']).must_equal(job.scheduled_at)
170+
assert(publish_span.attributes['messaging.active_job.scheduled_at'])
171171

172172
# The processing span isn't a 'scheduled' thing
173173
_(process_span.attributes['messaging.active_job.scheduled_at']).must_be_nil
@@ -185,15 +185,15 @@
185185
ActiveJob::Base.queue_adapter = :inline
186186
TestJob.perform_later
187187

188-
[send_span, process_span].each do |span|
188+
[publish_span, process_span].each do |span|
189189
_(span.attributes['messaging.system']).must_equal('inline')
190190
end
191191
end
192192

193193
it 'is set correctly for the async adapter' do
194194
TestJob.perform_later
195195

196-
[send_span, process_span].each do |span|
196+
[publish_span, process_span].each do |span|
197197
_(span.attributes['messaging.system']).must_equal('async')
198198
end
199199
end
@@ -232,7 +232,7 @@
232232
it 'generally sets other attributes as expected' do
233233
job = TestJob.perform_later
234234

235-
[send_span, process_span].each do |span|
235+
[publish_span, process_span].each do |span|
236236
_(span.attributes['code.namespace']).must_equal('TestJob')
237237
_(span.attributes['messaging.destination_kind']).must_equal('queue')
238238
_(span.attributes['messaging.system']).must_equal('async')
@@ -245,8 +245,8 @@
245245
describe 'when queue - default' do
246246
it 'names spans according to the job queue' do
247247
TestJob.set(queue: :foo).perform_later
248-
send_span = exporter.finished_spans.find { |s| s.name == 'foo send' }
249-
_(send_span).wont_be_nil
248+
publish_span = exporter.finished_spans.find { |s| s.name == 'foo publish' }
249+
_(publish_span).wont_be_nil
250250

251251
process_span = exporter.finished_spans.find { |s| s.name == 'foo process' }
252252
_(process_span).wont_be_nil
@@ -258,8 +258,8 @@
258258

259259
it 'names span according to the job class' do
260260
TestJob.set(queue: :foo).perform_later
261-
send_span = exporter.finished_spans.find { |s| s.name == 'TestJob send' }
262-
_(send_span).wont_be_nil
261+
publish_span = exporter.finished_spans.find { |s| s.name == 'TestJob publish' }
262+
_(publish_span).wont_be_nil
263263

264264
process_span = exporter.finished_spans.find { |s| s.name == 'TestJob process' }
265265
_(process_span).wont_be_nil
@@ -309,11 +309,11 @@
309309
it 'creates span links in separate traces' do
310310
TestJob.perform_later
311311

312-
_(send_span.trace_id).wont_equal(process_span.trace_id)
312+
_(publish_span.trace_id).wont_equal(process_span.trace_id)
313313

314314
_(process_span.total_recorded_links).must_equal(1)
315-
_(process_span.links[0].span_context.trace_id).must_equal(send_span.trace_id)
316-
_(process_span.links[0].span_context.span_id).must_equal(send_span.span_id)
315+
_(process_span.links[0].span_context.trace_id).must_equal(publish_span.trace_id)
316+
_(process_span.links[0].span_context.span_id).must_equal(publish_span.span_id)
317317
end
318318

319319
it 'propagates baggage' do
@@ -322,11 +322,11 @@
322322
BaggageJob.perform_later
323323
end
324324

325-
_(send_span.trace_id).wont_equal(process_span.trace_id)
325+
_(publish_span.trace_id).wont_equal(process_span.trace_id)
326326

327327
_(process_span.total_recorded_links).must_equal(1)
328-
_(process_span.links[0].span_context.trace_id).must_equal(send_span.trace_id)
329-
_(process_span.links[0].span_context.span_id).must_equal(send_span.span_id)
328+
_(process_span.links[0].span_context.trace_id).must_equal(publish_span.trace_id)
329+
_(process_span.links[0].span_context.span_id).must_equal(publish_span.span_id)
330330
_(process_span.attributes['success']).must_equal(true)
331331
end
332332
end
@@ -339,8 +339,8 @@
339339

340340
_(process_span.total_recorded_links).must_equal(0)
341341

342-
_(send_span.trace_id).must_equal(process_span.trace_id)
343-
_(process_span.parent_span_id).must_equal(send_span.span_id)
342+
_(publish_span.trace_id).must_equal(process_span.trace_id)
343+
_(process_span.parent_span_id).must_equal(publish_span.span_id)
344344
end
345345

346346
it 'propagates baggage' do
@@ -350,8 +350,8 @@
350350
end
351351
_(process_span.total_recorded_links).must_equal(0)
352352

353-
_(send_span.trace_id).must_equal(process_span.trace_id)
354-
_(process_span.parent_span_id).must_equal(send_span.span_id)
353+
_(publish_span.trace_id).must_equal(process_span.trace_id)
354+
_(process_span.parent_span_id).must_equal(publish_span.span_id)
355355
_(process_span.attributes['success']).must_equal(true)
356356
end
357357
end
@@ -364,8 +364,8 @@
364364

365365
_(process_span.total_recorded_links).must_equal(0)
366366

367-
_(send_span.trace_id).wont_equal(process_span.trace_id)
368-
_(process_span.parent_span_id).wont_equal(send_span.span_id)
367+
_(publish_span.trace_id).wont_equal(process_span.trace_id)
368+
_(process_span.parent_span_id).wont_equal(publish_span.span_id)
369369
end
370370

371371
it 'still propagates baggage' do
@@ -376,8 +376,8 @@
376376

377377
_(process_span.total_recorded_links).must_equal(0)
378378

379-
_(send_span.trace_id).wont_equal(process_span.trace_id)
380-
_(process_span.parent_span_id).wont_equal(send_span.span_id)
379+
_(publish_span.trace_id).wont_equal(process_span.trace_id)
380+
_(process_span.parent_span_id).wont_equal(publish_span.span_id)
381381
_(process_span.attributes['success']).must_equal(true)
382382
end
383383
end

instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def span_kind(client_method)
9595
def span_name(context, client_method)
9696
case client_method
9797
when SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH
98-
"#{MessagingHelper.queue_name(context)} send"
98+
"#{MessagingHelper.queue_name(context)} publish"
9999
when SQS_RECEIVE_MESSAGE
100100
"#{MessagingHelper.queue_name(context)} receive"
101101
else

instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
sns_client.publish message: 'msg', phone_number: '123456'
206206

207207
_(last_span.attributes['messaging.destination']).must_equal 'phone_number'
208-
_(last_span.name).must_equal 'phone_number send'
208+
_(last_span.name).must_equal 'phone_number publish'
209209
end
210210
end
211211
end

instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def self.with_send_span(channel, tracer, exchange, routing_key, &block)
1616
attributes = basic_attributes(channel, channel.connection, exchange, routing_key)
1717
destination = destination_name(exchange, routing_key)
1818

19-
tracer.in_span("#{destination} send", attributes: attributes, kind: :producer, &block)
19+
tracer.in_span("#{destination} publish", attributes: attributes, kind: :producer, &block)
2020
end
2121

2222
def self.with_process_span(channel, tracer, delivery_info, properties, &block)

instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/channel_test.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@
4848

4949
_(spans.size >= 3).must_equal(true)
5050

51-
send_span = spans.find { |span| span.name == "#{topic}.ruby.news send" }
52-
_(send_span).wont_be_nil
53-
_(send_span.kind).must_equal(:producer)
54-
_(send_span.attributes['messaging.system']).must_equal('rabbitmq')
55-
_(send_span.attributes['messaging.destination']).must_equal(topic)
56-
_(send_span.attributes['messaging.destination_kind']).must_equal('topic')
57-
_(send_span.attributes['messaging.protocol']).must_equal('AMQP')
58-
_(send_span.attributes['messaging.protocol_version']).must_equal('0.9.1')
59-
_(send_span.attributes['messaging.rabbitmq.routing_key']).must_equal('ruby.news')
60-
_(send_span.attributes['net.peer.name']).must_equal(host)
61-
_(send_span.attributes['net.peer.port']).must_equal(port.to_i)
51+
publish_span = spans.find { |span| span.name == "#{topic}.ruby.news publish" }
52+
_(publish_span).wont_be_nil
53+
_(publish_span.kind).must_equal(:producer)
54+
_(publish_span.attributes['messaging.system']).must_equal('rabbitmq')
55+
_(publish_span.attributes['messaging.destination']).must_equal(topic)
56+
_(publish_span.attributes['messaging.destination_kind']).must_equal('topic')
57+
_(publish_span.attributes['messaging.protocol']).must_equal('AMQP')
58+
_(publish_span.attributes['messaging.protocol_version']).must_equal('0.9.1')
59+
_(publish_span.attributes['messaging.rabbitmq.routing_key']).must_equal('ruby.news')
60+
_(publish_span.attributes['net.peer.name']).must_equal(host)
61+
_(publish_span.attributes['net.peer.port']).must_equal(port.to_i)
6262

6363
receive_span = spans.find { |span| span.name == "#{topic}.ruby.news receive" }
6464
_(receive_span).wont_be_nil
@@ -78,7 +78,7 @@
7878
_(process_span.trace_id).must_equal(receive_span.trace_id)
7979

8080
linked_span_context = process_span.links.first.span_context
81-
_(linked_span_context.trace_id).must_equal(send_span.trace_id)
82-
_(linked_span_context.span_id).must_equal(send_span.span_id)
81+
_(linked_span_context.trace_id).must_equal(publish_span.trace_id)
82+
_(linked_span_context.span_id).must_equal(publish_span.span_id)
8383
end
8484
end unless ENV['OMIT_SERVICES']

instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/consumer_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353

5454
_(spans.size >= 3).must_equal(true)
5555

56-
send_span = spans.find { |span| span.name == "#{topic}.ruby.news send" }
57-
_(send_span).wont_be_nil
58-
_(send_span.kind).must_equal(:producer)
56+
publish_span = spans.find { |span| span.name == "#{topic}.ruby.news publish" }
57+
_(publish_span).wont_be_nil
58+
_(publish_span.kind).must_equal(:producer)
5959

6060
receive_span = spans.find { |span| span.name == "#{topic}.ruby.news receive" }
6161
_(receive_span).wont_be_nil
@@ -68,7 +68,7 @@
6868
_(process_span.trace_id).must_equal(receive_span.trace_id)
6969

7070
linked_span_context = process_span.links.first.span_context
71-
_(linked_span_context.trace_id).must_equal(send_span.trace_id)
72-
_(linked_span_context.span_id).must_equal(send_span.span_id)
71+
_(linked_span_context.trace_id).must_equal(publish_span.trace_id)
72+
_(linked_span_context.span_id).must_equal(publish_span.span_id)
7373
end
7474
end unless ENV['OMIT_SERVICES']

instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/queue_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747

4848
queue.pop { |_delivery_info, _metadata, _payload| break }
4949

50-
send_span = spans.find { |span| span.name == ".#{queue_name} send" }
51-
_(send_span).wont_be_nil
50+
publish_span = spans.find { |span| span.name == ".#{queue_name} publish" }
51+
_(publish_span).wont_be_nil
5252

5353
receive_span = spans.find { |span| span.name == ".#{queue_name} receive" }
5454
_(receive_span).wont_be_nil
@@ -58,7 +58,7 @@
5858
_(process_span.kind).must_equal(:consumer)
5959

6060
linked_span_context = process_span.links.first.span_context
61-
_(linked_span_context.trace_id).must_equal(send_span.trace_id)
61+
_(linked_span_context.trace_id).must_equal(publish_span.trace_id)
6262
end
6363

6464
it 'traces messages returned' do

instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def instrument_enqueue(job, &block)
1717
return block.call(job) unless enabled?
1818

1919
attributes = build_attributes(job)
20-
attributes['messaging.operation'] = 'send'
20+
attributes['messaging.operation'] = 'publish'
2121
attributes.compact!
2222

23-
tracer.in_span("#{job_queue(job)} send", attributes: attributes, kind: :producer) do |span|
23+
tracer.in_span("#{job_queue(job)} publish", attributes: attributes, kind: :producer) do |span|
2424
yield job
2525
span.set_attribute('messaging.message_id', job.id.to_s)
2626
add_events(span, job)

instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ def job_data
6565
_(exporter.finished_spans.size).must_equal 1
6666

6767
_(span).must_be_kind_of OpenTelemetry::SDK::Trace::SpanData
68-
_(span.name).must_equal 'default send'
68+
_(span.name).must_equal 'default publish'
6969
_(span.attributes['messaging.system']).must_equal 'delayed_job'
7070
_(span.attributes['messaging.destination']).must_equal 'default'
7171
_(span.attributes['messaging.destination_kind']).must_equal 'queue'
7272
_(span.attributes['messaging.delayed_job.name']).must_equal 'BasicPayload'
7373
_(span.attributes['messaging.delayed_job.priority']).must_equal 0
74-
_(span.attributes['messaging.operation']).must_equal 'send'
74+
_(span.attributes['messaging.operation']).must_equal 'publish'
7575
_(span.attributes['messaging.message_id']).must_be_kind_of String
7676

7777
_(span.events.size).must_equal 2
@@ -122,7 +122,7 @@ def job_data
122122
_(exporter.finished_spans).must_equal []
123123
job_enqueue
124124
_(exporter.finished_spans.size).must_equal 1
125-
_(exporter.finished_spans.first.name).must_equal 'default send'
125+
_(exporter.finished_spans.first.name).must_equal 'default publish'
126126
job_run
127127
_(exporter.finished_spans.size).must_equal 2
128128

0 commit comments

Comments
 (0)