chore: add sc to oban (#138)

This commit is contained in:
Yordis Prieto 2022-12-14 18:48:27 -05:00 committed by GitHub
parent d1ec189362
commit 1e2ae6707c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 15 deletions

View File

@ -18,7 +18,9 @@ defmodule OpentelemetryOban do
alias Ecto.Changeset alias Ecto.Changeset
alias OpenTelemetry.Span alias OpenTelemetry.Span
alias OpenTelemetry.SemanticConventions.Trace
require Trace
require OpenTelemetry.Tracer require OpenTelemetry.Tracer
@doc """ @doc """
@ -128,10 +130,10 @@ defmodule OpentelemetryOban do
worker = Changeset.get_field(changeset, :worker, "unknown") worker = Changeset.get_field(changeset, :worker, "unknown")
%{ %{
"messaging.system": :oban, Trace.messaging_system() => :oban,
"messaging.destination": queue, Trace.messaging_destination() => queue,
"messaging.destination_kind": :queue, Trace.messaging_destination_kind() => :queue,
"messaging.oban.worker": worker :"messaging.oban.worker" => worker
} }
end end

View File

@ -1,5 +1,8 @@
defmodule OpentelemetryOban.JobHandler do defmodule OpentelemetryOban.JobHandler do
alias OpenTelemetry.Span alias OpenTelemetry.Span
alias OpenTelemetry.SemanticConventions.Trace
require Trace
@tracer_id __MODULE__ @tracer_id __MODULE__
@ -57,18 +60,18 @@ defmodule OpentelemetryOban.JobHandler do
OpenTelemetry.Tracer.set_current_span(:undefined) OpenTelemetry.Tracer.set_current_span(:undefined)
attributes = %{ attributes = %{
"messaging.system": :oban, Trace.messaging_system() => :oban,
"messaging.destination": queue, Trace.messaging_destination() => queue,
"messaging.destination_kind": :queue, Trace.messaging_destination_kind() => :queue,
"messaging.operation": :process, Trace.messaging_operation() => :process,
"messaging.oban.job_id": id, :"messaging.oban.job_id" => id,
"messaging.oban.worker": worker, :"messaging.oban.worker" => worker,
"messaging.oban.priority": priority, :"messaging.oban.priority" => priority,
"messaging.oban.attempt": attempt, :"messaging.oban.attempt" => attempt,
"messaging.oban.max_attempts": max_attempts, :"messaging.oban.max_attempts" => max_attempts,
"messaging.oban.inserted_at": :"messaging.oban.inserted_at" =>
if(inserted_at, do: DateTime.to_iso8601(inserted_at), else: nil), if(inserted_at, do: DateTime.to_iso8601(inserted_at), else: nil),
"messaging.oban.scheduled_at": DateTime.to_iso8601(scheduled_at) :"messaging.oban.scheduled_at" => DateTime.to_iso8601(scheduled_at)
} }
span_name = "#{worker} process" span_name = "#{worker} process"

View File

@ -41,6 +41,7 @@ defmodule OpentelemetryOban.MixProject do
{:oban, "~> 2.0"}, {:oban, "~> 2.0"},
{:opentelemetry_api, "~> 1.0"}, {:opentelemetry_api, "~> 1.0"},
{:opentelemetry_telemetry, "~> 1.0.0"}, {:opentelemetry_telemetry, "~> 1.0.0"},
{:opentelemetry_semantic_conventions, "~> 0.1.0"},
{:opentelemetry, "~> 1.0", only: [:test]}, {:opentelemetry, "~> 1.0", only: [:test]},
{:opentelemetry_exporter, "~> 1.0", only: [:test]}, {:opentelemetry_exporter, "~> 1.0", only: [:test]},
{:telemetry, "~> 0.4 or ~> 1.0"}, {:telemetry, "~> 0.4 or ~> 1.0"},

View File

@ -21,6 +21,7 @@
"opentelemetry": {:hex, :opentelemetry, "1.1.2", "77ba2fd2fee67bebde590851a4afeda45b3f298310aa410a2a3804b364cb598a", [:rebar3], [{:opentelemetry_api, "~> 1.1", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "5c60be189d6aed64a9fd17055f72c93eab144be441e625276c3c95533e6bb4c7"}, "opentelemetry": {:hex, :opentelemetry, "1.1.2", "77ba2fd2fee67bebde590851a4afeda45b3f298310aa410a2a3804b364cb598a", [:rebar3], [{:opentelemetry_api, "~> 1.1", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "5c60be189d6aed64a9fd17055f72c93eab144be441e625276c3c95533e6bb4c7"},
"opentelemetry_api": {:hex, :opentelemetry_api, "1.1.1", "3b43877c456c8a7f5448a95d9bf4fb4bb8cc2abbbea2c62d5f8e8c538b4af14f", [:mix, :rebar3], [], "hexpm", "a9554b3208b60a70043318d051ea78fbbc7a1b8f4c418ebc16ccb40015995675"}, "opentelemetry_api": {:hex, :opentelemetry_api, "1.1.1", "3b43877c456c8a7f5448a95d9bf4fb4bb8cc2abbbea2c62d5f8e8c538b4af14f", [:mix, :rebar3], [], "hexpm", "a9554b3208b60a70043318d051ea78fbbc7a1b8f4c418ebc16ccb40015995675"},
"opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.2.2", "3966c56656627ef7db6c34c4ce28d44ac8629dcd065a310d7c33712fc2a1cfe3", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.1", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.1", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:tls_certificate_check, "~> 1.11", [hex: :tls_certificate_check, repo: "hexpm", optional: false]}], "hexpm", "5c11adeda19e0d203a04efe92cdd7a183da4b09ae8acaba7608e9303fa258e74"}, "opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.2.2", "3966c56656627ef7db6c34c4ce28d44ac8629dcd065a310d7c33712fc2a1cfe3", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.1", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.1", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:tls_certificate_check, "~> 1.11", [hex: :tls_certificate_check, repo: "hexpm", optional: false]}], "hexpm", "5c11adeda19e0d203a04efe92cdd7a183da4b09ae8acaba7608e9303fa258e74"},
"opentelemetry_semantic_conventions": {:hex, :opentelemetry_semantic_conventions, "0.1.0", "0a7463c0ec4541d9c8e09ee99bd7b5480fa6f90f40313a6d071fd7521b5a712f", [:mix, :rebar3], [], "hexpm", "eccf41bc7afec299484075aff570bf504a2f7e5c38fbcdaceb33a6d6b901448d"},
"opentelemetry_telemetry": {:hex, :opentelemetry_telemetry, "1.0.0", "d5982a319e725fcd2305b306b65c18a86afdcf7d96821473cf0649ff88877615", [:mix, :rebar3], [{:opentelemetry_api, "~> 1.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.3.0", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "3401d13a1d4b7aa941a77e6b3ec074f0ae77f83b5b2206766ce630123a9291a9"}, "opentelemetry_telemetry": {:hex, :opentelemetry_telemetry, "1.0.0", "d5982a319e725fcd2305b306b65c18a86afdcf7d96821473cf0649ff88877615", [:mix, :rebar3], [{:opentelemetry_api, "~> 1.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.3.0", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "3401d13a1d4b7aa941a77e6b3ec074f0ae77f83b5b2206766ce630123a9291a9"},
"postgrex": {:hex, :postgrex, "0.16.5", "fcc4035cc90e23933c5d69a9cd686e329469446ef7abba2cf70f08e2c4b69810", [:mix], [{:connection, "~> 1.1", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "edead639dc6e882618c01d8fc891214c481ab9a3788dfe38dd5e37fd1d5fb2e8"}, "postgrex": {:hex, :postgrex, "0.16.5", "fcc4035cc90e23933c5d69a9cd686e329469446ef7abba2cf70f08e2c4b69810", [:mix], [{:connection, "~> 1.1", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "edead639dc6e882618c01d8fc891214c481ab9a3788dfe38dd5e37fd1d5fb2e8"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},