# `AshHooks.Telemetry`
[🔗](https://github.com/baselabs/ash_hooks/blob/v3.0.0/lib/ash_hooks/telemetry.ex#L1)

Lifecycle events for ingress, queue admission, and outbound delivery.

Events carry identifiers, measurements, fixed atoms, and classified reasons.
The package omits bodies, payloads, and resolved signing secrets. For a
secret fingerprint in your own event, `AshHooks.Telemetry.fingerprint/1`
returns an eight-character hexadecimal value; package events do not use it.

Attach handlers to consume these best-effort `:telemetry.execute/3` events:

  * `[:ash_hooks, :ingress, :verify]` — `%{duration_ms}`; `%{source,
    outcome: :ok | :invalid, reason: atom | nil}` (the five
    `AshHooks.Errors.Invalid` classes, or nil for unknown-class
    pre-verify failures)
  * `[:ash_hooks, :ingress, :dedup]` — `%{source, outcome: :created |
    :duplicate}`
  * `[:ash_hooks, :ingress, :claim]` — `%{source, outcome: :claimed |
    :lease_held}`
  * `[:ash_hooks, :dispatch, :enqueue_failed]` — `%{endpoint_id,
    event_uuid, reason}` (classified, contents-free)
  * `[:ash_hooks, :delivery, :attempt]` — `%{endpoint_id, event_uuid,
    attempts}`
  * `[:ash_hooks, :delivery, :result]` — `%{endpoint_id, event_uuid,
    status: :succeeded | :failed_retryable | :dead_letter,
    response_status: integer | nil, reason: binary | nil}`
  * `[:ash_hooks, :delivery, :backoff]` — `%{endpoint_id, event_uuid,
    attempts, delay_seconds}`
  * `[:ash_hooks, :delivery, :dead_letter]` — `%{endpoint_id,
    event_uuid, reason, response_status}`
  * `[:ash_hooks, :delivery, :disable]` — `%{endpoint_id, reason:
    :gone_410}`
  * `[:ash_hooks, :worker, :invalid_runtime_config]` — `%{reason:
    binary}` (the fixed validation vocabulary: `callback_failed`,
    `unknown_key`, `not_positive_integer`, `backoff_inversion`,
    `envelope_exceeded`, `oban_ceiling_exceeded`); the job failed before
    any delivery work and the delivery row is untouched
  * `[:ash_hooks, :attempt, :record_failed]` — `%{endpoint_id,
    event_uuid, reason}` (classified): an attempt-history row could not
    be written; the delivery result itself succeeded and remains the
    contract
  * `[:ash_hooks, :delivery, :resend]` — `%{endpoint_id, event_uuid,
    requested_by}`: a terminal row was re-armed (resend or replay)
  * `[:ash_hooks, :delivery, :test]` — `%{endpoint_id, type}`: a signed
    synthetic test event is about to send (outside subscriptions; the
    payload marks itself when synthesized)
  * `[:ash_hooks, :endpoint, :roll]` — `%{endpoint_id}`: an endpoint's
    signing secret reference was rolled (the overlap window began)
  * `[:ash_hooks, :event, :record_failed]` — `%{event_uuid, reason}`
    (classified): the event log could not record a dispatched event;
    the fanout was unaffected
  * `[:ash_hooks, :endpoint, :disable_warning]` — `%{endpoint_id,
    failure_share, attempts}`: the sustained-failure policy sees an
    endpoint failing at the warning thresholds — notify before the
    breaker opens
  * `[:ash_hooks, :endpoint, :disable]` — `%{endpoint_id, reason}`:
    `reason: :gone_410` (the 410 rule) or `:sustained_failure` (the
    auto-disable policy); the endpoint was durably disabled

`:telemetry.execute/3` matches exact event names, so consume the
whole surface with one `attach_many`:

    :telemetry.attach_many("my-ash-hooks", [
      [:ash_hooks, :ingress, :verify],
      [:ash_hooks, :ingress, :dedup],
      [:ash_hooks, :ingress, :claim],
      [:ash_hooks, :dispatch, :enqueue_failed],
      [:ash_hooks, :delivery, :attempt],
      [:ash_hooks, :delivery, :result],
      [:ash_hooks, :delivery, :backoff],
      [:ash_hooks, :delivery, :dead_letter],
      [:ash_hooks, :delivery, :disable],
      [:ash_hooks, :worker, :invalid_runtime_config],
      [:ash_hooks, :attempt, :record_failed],
      [:ash_hooks, :delivery, :resend],
      [:ash_hooks, :delivery, :test],
      [:ash_hooks, :endpoint, :roll],
      [:ash_hooks, :endpoint, :disable_warning],
      [:ash_hooks, :endpoint, :disable],
      [:ash_hooks, :event, :record_failed]
    ], fn event, measurements, metadata, _ ->
      # Forward these measurements and identifiers to your metrics system.
    end, nil)

# `classify_token`

```elixir
@spec classify_token(term()) :: binary()
```

The shared contents-free error classifier. Only the fixed internal
vocabulary and HTTP status classifications survive. Caller-selected
strings and atoms collapse to "unclassified", including strings that
happen to have the same spelling pattern as an internal token.

# `fingerprint`

```elixir
@spec fingerprint(binary()) :: String.t()
```

Returns the first eight hexadecimal characters of a secret's SHA-256 hash
for correlation. Collisions are possible; do not use this fingerprint as a
unique identifier or authentication credential.

---

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