OeditusCredo.Check.Warning.MissingTelemetryInObanWorker (OeditusCredo v0.6.0)

View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of normal and works with any version of Elixir.

Explanation

Oban workers should emit telemetry events for observability.

Instrumenting Oban workers with telemetry allows monitoring job execution, duration, success/failure rates, and helps debug production issues.

Bad:

defmodule MyApp.Worker do
  use Oban.Worker

  def perform(%Oban.Job{args: args}) do
    do_work(args)
  end
end

Good:

defmodule MyApp.Worker do
  use Oban.Worker

  def perform(%Oban.Job{args: args}) do
    :telemetry.span([:oban, :job, :execute], %{worker: __MODULE__}, fn ->
      result = do_work(args)
      {result, %{}}
    end)
  end
end

Check-Specific Parameters

Use the following parameters to configure this check:

:exclude_test_files

Set to true to skip test files (default: false)

This parameter defaults to nil.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.