eecb238cff
By default a new trace is automatically started when a job is processed by monitoring these events: * `[:oban, :job, :start]` — at the point a job is fetched from the database and will execute * `[:oban, :job, :stop]` — after a job succeeds and the success is recorded in the database * `[:oban, :job, :exception]` — after a job fails and the failure is recorded in the database To also record a span when a job is created and to link traces together `Oban.insert/2` has to be replaced by `OpentelemetryOban.insert/2`. Before: ```elixir %{id: 1, in_the: "business", of_doing: "business"} |> MyApp.Business.new() |> Oban.insert() ``` After: ```elixir %{id: 1, in_the: "business", of_doing: "business"} |> MyApp.Business.new() |> OpentelemetryOban.insert() ``` Co-authored-by: Tristan Sloughter <t@crashfast.com>
33 lines
753 B
Elixir
33 lines
753 B
Elixir
defmodule DataCase do
|
|
@moduledoc """
|
|
This module defines the setup for tests requiring access to the data layer.
|
|
|
|
You may define functions here to be used as helpers in your tests.
|
|
|
|
Finally, if the test case interacts with the database, it cannot be async.
|
|
For this reason, every test runs inside a transaction which is reset at the
|
|
beginning of the test unless the test case is marked as async.
|
|
"""
|
|
|
|
use ExUnit.CaseTemplate
|
|
|
|
using do
|
|
quote do
|
|
use Oban.Testing, repo: TestRepo
|
|
|
|
import Ecto
|
|
import DataCase
|
|
end
|
|
end
|
|
|
|
setup tags do
|
|
:ok = Ecto.Adapters.SQL.Sandbox.checkout(TestRepo)
|
|
|
|
unless tags[:async] do
|
|
Ecto.Adapters.SQL.Sandbox.mode(TestRepo, {:shared, self()})
|
|
end
|
|
|
|
:ok
|
|
end
|
|
end
|