Skip to content

Commit 02bff19

Browse files
committed
Fix Oban test failures
Span names Exception atom instead of string and Oban Job priority after insert
1 parent bfef35d commit 02bff19

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

instrumentation/opentelemetry_oban/lib/opentelemetry_oban.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ defmodule OpentelemetryOban do
5454
attributes = attributes_before_insert(changeset)
5555
worker = Changeset.get_field(changeset, :worker)
5656

57-
OpenTelemetry.Tracer.with_span "#{worker} send", attributes: attributes, kind: :producer do
57+
OpenTelemetry.Tracer.with_span "#{worker}.send", attributes: attributes, kind: :producer do
5858
changeset = add_tracing_information_to_meta(changeset)
5959

6060
case Oban.insert(name, changeset) do
@@ -76,7 +76,7 @@ defmodule OpentelemetryOban do
7676
attributes = attributes_before_insert(changeset)
7777
worker = Changeset.get_field(changeset, :worker)
7878

79-
OpenTelemetry.Tracer.with_span "#{worker} send", attributes: attributes, kind: :producer do
79+
OpenTelemetry.Tracer.with_span "#{worker}.send", attributes: attributes, kind: :producer do
8080
changeset = add_tracing_information_to_meta(changeset)
8181

8282
try do

instrumentation/opentelemetry_oban/test/opentelemetry_oban/plugin_handler_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ defmodule OpentelemetryOban.PluginHandlerTest do
103103

104104
[
105105
event(
106-
name: "exception",
106+
name: :exception,
107107
attributes: event_attributes
108108
)
109109
] = :otel_events.list(events)

instrumentation/opentelemetry_oban/test/opentelemetry_oban_test.exs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ defmodule OpentelemetryObanTest do
3737

3838
assert_receive {:span,
3939
span(
40-
name: "TestJob send",
40+
name: "TestJob.send",
4141
attributes: attributes,
4242
parent_span_id: :undefined,
4343
kind: :producer,
@@ -49,7 +49,7 @@ defmodule OpentelemetryObanTest do
4949
"messaging.system": :oban,
5050
"oban.job.job_id": _job_id,
5151
"oban.job.max_attempts": 1,
52-
"oban.job.priority": 0,
52+
"oban.job.priority": nil,
5353
"oban.job.worker": "TestJob"
5454
} = :otel_attributes.map(attributes)
5555
end
@@ -65,7 +65,7 @@ defmodule OpentelemetryObanTest do
6565

6666
assert_receive {:span,
6767
span(
68-
name: "TestJob send",
68+
name: "TestJob.send",
6969
attributes: _attributes,
7070
trace_id: ^root_trace_id,
7171
parent_span_id: ^root_span_id,
@@ -88,7 +88,7 @@ defmodule OpentelemetryObanTest do
8888

8989
assert_receive {:span,
9090
span(
91-
name: "TestJob send",
91+
name: "TestJob.send",
9292
attributes: _attributes,
9393
trace_id: send_trace_id,
9494
span_id: send_span_id,
@@ -98,7 +98,7 @@ defmodule OpentelemetryObanTest do
9898

9999
assert_receive {:span,
100100
span(
101-
name: "TestJob process",
101+
name: "TestJob.process",
102102
attributes: _attributes,
103103
kind: :consumer,
104104
status: :undefined,
@@ -120,7 +120,7 @@ defmodule OpentelemetryObanTest do
120120

121121
assert_receive {:span,
122122
span(
123-
name: "TestJob process",
123+
name: "TestJob.process",
124124
attributes: _attributes,
125125
kind: :consumer,
126126
status: :undefined,
@@ -137,7 +137,7 @@ defmodule OpentelemetryObanTest do
137137

138138
assert_receive {:span,
139139
span(
140-
name: "TestJob process",
140+
name: "TestJob.process",
141141
attributes: attributes,
142142
kind: :consumer,
143143
status: :undefined
@@ -165,7 +165,7 @@ defmodule OpentelemetryObanTest do
165165

166166
assert_receive {:span,
167167
span(
168-
name: "TestJobThatReturnsError process",
168+
name: "TestJobThatReturnsError.process",
169169
attributes: attributes,
170170
kind: :consumer,
171171
events: events,
@@ -187,7 +187,7 @@ defmodule OpentelemetryObanTest do
187187

188188
[
189189
event(
190-
name: "exception",
190+
name: :exception,
191191
attributes: event_attributes
192192
)
193193
] = :otel_events.list(events)
@@ -206,14 +206,14 @@ defmodule OpentelemetryObanTest do
206206

207207
assert_receive {:span,
208208
span(
209-
name: "TestJobThatReturnsError send",
209+
name: "TestJobThatReturnsError.send",
210210
trace_id: send_trace_id,
211211
span_id: send_span_id
212212
)}
213213

214214
assert_receive {:span,
215215
span(
216-
name: "TestJobThatReturnsError process",
216+
name: "TestJobThatReturnsError.process",
217217
status: ^expected_status,
218218
trace_id: first_process_trace_id,
219219
links: job_1_links
@@ -223,7 +223,7 @@ defmodule OpentelemetryObanTest do
223223

224224
assert_receive {:span,
225225
span(
226-
name: "TestJobThatReturnsError process",
226+
name: "TestJobThatReturnsError.process",
227227
status: ^expected_status,
228228
trace_id: second_process_trace_id,
229229
links: job_2_links
@@ -242,7 +242,7 @@ defmodule OpentelemetryObanTest do
242242

243243
assert_receive {:span,
244244
span(
245-
name: "TestJobThatThrowsException process",
245+
name: "TestJobThatThrowsException.process",
246246
attributes: attributes,
247247
kind: :consumer,
248248
events: events,
@@ -264,7 +264,7 @@ defmodule OpentelemetryObanTest do
264264

265265
[
266266
event(
267-
name: "exception",
267+
name: :exception,
268268
attributes: event_attributes
269269
)
270270
] = :otel_events.list(events)
@@ -279,7 +279,7 @@ defmodule OpentelemetryObanTest do
279279

280280
assert_receive {:span,
281281
span(
282-
name: "TestJobWithInnerSpan process",
282+
name: "TestJobWithInnerSpan.process",
283283
kind: :consumer,
284284
trace_id: trace_id,
285285
span_id: process_span_id
@@ -297,8 +297,8 @@ defmodule OpentelemetryObanTest do
297297
test "OpentelemetryOban.insert!/2 returns job on successful insert" do
298298
%Oban.Job{} = OpentelemetryOban.insert!(TestJob.new(%{}))
299299
assert %{success: 1, failure: 0} = Oban.drain_queue(queue: :events)
300-
assert_receive {:span, span(name: "TestJob send")}
301-
assert_receive {:span, span(name: "TestJob process")}
300+
assert_receive {:span, span(name: "TestJob.send")}
301+
assert_receive {:span, span(name: "TestJob.process")}
302302
end
303303

304304
test "OpentelemetryOban.insert!/2 raises an error on failed insert" do
@@ -313,22 +313,22 @@ defmodule OpentelemetryObanTest do
313313

314314
assert_receive {:span,
315315
span(
316-
name: "TestJob send",
316+
name: "TestJob.send",
317317
events: events,
318318
status: ^expected_status
319319
)}
320320

321321
[
322322
event(
323-
name: "exception",
323+
name: :exception,
324324
attributes: event_attributes
325325
)
326326
] = :otel_events.list(events)
327327

328328
assert [:"exception.message", :"exception.stacktrace", :"exception.type"] ==
329329
Enum.sort(Map.keys(:otel_attributes.map(event_attributes)))
330330

331-
refute_received {:span, span(name: "TestJob process")}
331+
refute_received {:span, span(name: "TestJob.process")}
332332
end
333333

334334
test "tracing information is propagated when using insert_all/2" do
@@ -351,7 +351,7 @@ defmodule OpentelemetryObanTest do
351351

352352
assert_receive {:span,
353353
span(
354-
name: "TestJob process",
354+
name: "TestJob.process",
355355
attributes: _attributes,
356356
kind: :consumer,
357357
status: :undefined,
@@ -363,7 +363,7 @@ defmodule OpentelemetryObanTest do
363363

364364
assert_receive {:span,
365365
span(
366-
name: "TestJob process",
366+
name: "TestJob.process",
367367
attributes: _attributes,
368368
kind: :consumer,
369369
status: :undefined,
@@ -383,6 +383,6 @@ defmodule OpentelemetryObanTest do
383383
test "works with Oban.Testing.perform_job helper function" do
384384
Oban.Testing.perform_job(TestJob, %{}, repo: TestRepo)
385385

386-
assert_receive {:span, span(name: "TestJob process")}
386+
assert_receive {:span, span(name: "TestJob.process")}
387387
end
388388
end

0 commit comments

Comments
 (0)