-
Notifications
You must be signed in to change notification settings - Fork 150
Update semantic conventions in opentelemetry_oban #528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| defmodule OpentelemetryOban.JobHandler do | ||
| alias OpenTelemetry.Span | ||
| alias OpenTelemetry.SemanticConventions.Trace | ||
|
|
||
| require Trace | ||
| alias OpenTelemetry.SemConv.Incubating.MessagingAttributes | ||
|
|
||
| @tracer_id __MODULE__ | ||
|
|
||
|
|
@@ -60,10 +58,12 @@ defmodule OpentelemetryOban.JobHandler do | |
| OpenTelemetry.Tracer.set_current_span(:undefined) | ||
|
|
||
| attributes = %{ | ||
| Trace.messaging_system() => :oban, | ||
| Trace.messaging_destination() => queue, | ||
| Trace.messaging_destination_kind() => :queue, | ||
| Trace.messaging_operation() => :process, | ||
| MessagingAttributes.messaging_system() => :oban, | ||
| MessagingAttributes.messaging_message_id() => id, | ||
| MessagingAttributes.messaging_client_id() => worker, | ||
| MessagingAttributes.messaging_destination_name() => queue, | ||
| MessagingAttributes.messaging_operation_type() => | ||
| MessagingAttributes.messaging_operation_type_values().process, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the warning message displayed in the top of https://opentelemetry.io/docs/specs/semconv/messaging/ means that the migration needs to provide a
|
||
| :"oban.job.job_id" => id, | ||
| :"oban.job.worker" => worker, | ||
| :"oban.job.priority" => priority, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,7 +103,7 @@ defmodule OpentelemetryOban.PluginHandlerTest do | |
|
|
||
| [ | ||
| event( | ||
| name: "exception", | ||
| name: :exception, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was already fixed separately in #558 |
||
| attributes: event_attributes | ||
| ) | ||
| ] = :otel_events.list(events) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ defmodule OpentelemetryObanTest do | |
| end | ||
|
|
||
| test "records span on job insertion" do | ||
| OpentelemetryOban.insert(TestJob.new(%{})) | ||
| {:ok, %{id: id}} = OpentelemetryOban.insert(TestJob.new(%{})) | ||
| assert %{success: 1, failure: 0} = Oban.drain_queue(queue: :events) | ||
|
|
||
| assert_receive {:span, | ||
|
|
@@ -45,12 +45,14 @@ defmodule OpentelemetryObanTest do | |
| )} | ||
|
|
||
| assert %{ | ||
| "messaging.destination": "events", | ||
| "messaging.destination_kind": :queue, | ||
| "messaging.destination.name": "events", | ||
| "oban.job.job_id": _job_id, | ||
| "oban.job.max_attempts": 1, | ||
| "oban.job.priority": 0, | ||
| "oban.job.worker": "TestJob", | ||
| "messaging.message.id": ^id, | ||
| "messaging.client.id": "TestJob", | ||
| "messaging.operation.type": :create, | ||
| "messaging.system": :oban | ||
| } = :otel_attributes.map(attributes) | ||
| end | ||
|
|
@@ -133,7 +135,7 @@ defmodule OpentelemetryObanTest do | |
| end | ||
|
|
||
| test "records spans for successful Oban jobs" do | ||
| OpentelemetryOban.insert(TestJob.new(%{})) | ||
| {:ok, %{id: id}} = OpentelemetryOban.insert(TestJob.new(%{})) | ||
| assert %{success: 1, failure: 0} = Oban.drain_queue(queue: :events) | ||
|
|
||
| assert_receive {:span, | ||
|
|
@@ -145,22 +147,23 @@ defmodule OpentelemetryObanTest do | |
| )} | ||
|
|
||
| assert %{ | ||
| "messaging.destination": "events", | ||
| "messaging.destination_kind": :queue, | ||
| "messaging.destination.name": "events", | ||
| "oban.job.attempt": 1, | ||
| "oban.job.inserted_at": _inserted_at, | ||
| "oban.job.job_id": _job_id, | ||
| "oban.job.job_id": ^id, | ||
| "oban.job.max_attempts": 1, | ||
| "oban.job.priority": 0, | ||
| "oban.job.scheduled_at": _scheduled_at, | ||
| "oban.job.worker": "TestJob", | ||
| "messaging.operation": :process, | ||
| "messaging.message.id": ^id, | ||
| "messaging.client.id": "TestJob", | ||
| "messaging.operation.type": :process, | ||
| "messaging.system": :oban | ||
| } = :otel_attributes.map(attributes) | ||
| end | ||
|
|
||
| test "records spans for Oban jobs that stop with {:error, :something}" do | ||
| OpentelemetryOban.insert(TestJobThatReturnsError.new(%{})) | ||
| {:ok, %{id: id}} = OpentelemetryOban.insert(TestJobThatReturnsError.new(%{})) | ||
| assert %{success: 0, discard: 1} = Oban.drain_queue(queue: :events) | ||
|
|
||
| expected_status = OpenTelemetry.status(:error, "") | ||
|
|
@@ -175,22 +178,23 @@ defmodule OpentelemetryObanTest do | |
| )} | ||
|
|
||
| assert %{ | ||
| "messaging.destination": "events", | ||
| "messaging.destination_kind": :queue, | ||
| "oban.job.attempt": 1, | ||
| "oban.job.inserted_at": _inserted_at, | ||
| "oban.job.job_id": _job_id, | ||
| "oban.job.job_id": ^id, | ||
| "oban.job.max_attempts": 1, | ||
| "oban.job.priority": 0, | ||
| "oban.job.scheduled_at": _scheduled_at, | ||
| "oban.job.worker": "TestJobThatReturnsError", | ||
| "messaging.operation": :process, | ||
| "messaging.system": :oban | ||
| "messaging.destination.name": "events", | ||
| "messaging.operation.type": :process, | ||
| "messaging.system": :oban, | ||
| "messaging.message.id": ^id, | ||
| "messaging.client.id": "TestJobThatReturnsError" | ||
| } = :otel_attributes.map(attributes) | ||
|
|
||
| [ | ||
| event( | ||
| name: "exception", | ||
| name: :exception, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was already fixed separately in #558 |
||
| attributes: event_attributes | ||
| ) | ||
| ] = :otel_events.list(events) | ||
|
|
@@ -238,7 +242,7 @@ defmodule OpentelemetryObanTest do | |
| end | ||
|
|
||
| test "records spans for Oban jobs that stop with an exception" do | ||
| OpentelemetryOban.insert(TestJobThatThrowsException.new(%{})) | ||
| {:ok, %{id: id}} = OpentelemetryOban.insert(TestJobThatThrowsException.new(%{})) | ||
| assert %{success: 0, discard: 1} = Oban.drain_queue(queue: :events) | ||
|
|
||
| expected_status = OpenTelemetry.status(:error, "") | ||
|
|
@@ -253,22 +257,23 @@ defmodule OpentelemetryObanTest do | |
| )} | ||
|
|
||
| assert %{ | ||
| "messaging.destination": "events", | ||
| "messaging.destination_kind": :queue, | ||
| "messaging.destination.name": "events", | ||
| "oban.job.attempt": 1, | ||
| "oban.job.inserted_at": _inserted_at, | ||
| "oban.job.job_id": _job_id, | ||
| "oban.job.job_id": ^id, | ||
| "oban.job.max_attempts": 1, | ||
| "oban.job.priority": 0, | ||
| "oban.job.scheduled_at": _scheduled_at, | ||
| "oban.job.worker": "TestJobThatThrowsException", | ||
| "messaging.operation": :process, | ||
| "messaging.operation.type": :process, | ||
| "messaging.message.id": ^id, | ||
| "messaging.client.id": "TestJobThatThrowsException", | ||
| "messaging.system": :oban | ||
| } = :otel_attributes.map(attributes) | ||
|
|
||
| [ | ||
| event( | ||
| name: "exception", | ||
| name: :exception, | ||
| attributes: event_attributes | ||
| ) | ||
| ] = :otel_events.list(events) | ||
|
|
@@ -324,7 +329,7 @@ defmodule OpentelemetryObanTest do | |
|
|
||
| [ | ||
| event( | ||
| name: "exception", | ||
| name: :exception, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was already fixed separately in #558 |
||
| attributes: event_attributes | ||
| ) | ||
| ] = :otel_events.list(events) | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see here that you're keeping the existing interpretation that a "Destination" is an Oban queue.
For what is worth and for the record, noting that this other pull request (#436 (comment)) is making a different interpretation in that a "Destination" is the Oban Worker and the "Consumer group" is the Oban queue.