# `JoobQ.Telemetry`
[🔗](https://github.com/azutoolkit/joobqui/tree/master/sdks/elixir/blob/main/lib/joobq/telemetry.ex#L2)

The `:telemetry` events of JoobQ. Each is a span: `:start` (measurements `system_time`, `monotonic_time`), then
`:stop` or `:exception` (measurements `duration`, `monotonic_time`, in native time units).

| Event | Metadata | `:stop` adds |
|-------|----------|--------------|
| `[:joobq, :enqueue, *]` | `instance`, `queue`, `job_type` | `result`, `status`, `jid`, `reason` |
| `[:joobq, :schedule, *]` | `instance`, `schedule`, `queue`, `job_type` | `result`, `reason` |
| `[:joobq, :rate_limit, *]` | `instance`, `limit`, `period_ms` (never the key) | `result`, `allowed`, `reason` |
| `[:joobq, :batch, *]` | `instance`, `size` | `result`, `reason`, `batch_id` |
| `[:joobq, :job, *]` | `instance`, `queue`, `job_type`, `jid`, `attempt`, `task_kind` | `outcome`, `retryable`, `error_class` |
| `[:joobq, :workflow, *]` | `instance`, `call` (`:start`, `:signal`, ...), `name` | `result`, `reason` |
| `[:joobq, :blueprint, *]` | `instance`, `workflow` | `result` (`:registered`, `:refused`, `:retry`) |
| `[:joobq, :request, *]` | `name`, `method`, `path` | `status` |

`[:joobq, :batch, *]` is `create_batch/2`'s; `get_batch/2` has only the request span. An enqueue's `result` is
`:ok` or `:error`, `status` the gateway's (`"enqueued"`, `"deduplicated"`, ...) and `reason` a `JoobQ.Error`
reason. A job's `outcome` is `:complete` or `:fail`. A request's `path` names a call
whose path holds a lease token by its pattern (`/tasks/:token/heartbeat`).

`:exception` adds `kind` (`:error`, `:exit`, `:throw`) and `error_class` (an exception's module name, or the kind),
never the reason or the stack trace. A job's `:exception` is a raise, an exit or a throw out of its handler or
middleware, or a run stopped by its `:timeout`; a returned `{:error, reason}` is a `:stop` with `outcome: :fail`.
An `enqueue/4` whose options are wrong raises after its `:exception` event; `enqueue_async/4` checks them before
its task starts, so it raises before any event. A job still running when a stop's `:drain_timeout` ends is
stopped with the worker: its `:start` has no `:stop` or `:exception`. A handler of `[:joobq, :job, :stop]` runs in
the job's process before the job's slot is free, and once the run has ended its span its `:timeout` no longer
stops it: a handler must not block. None of these events carries a payload, an
output, a lease token or the SDK token (Finch's own `[:finch, ...]` events carry the request, token included).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
