# `NoNoncense.Telemetry`
[🔗](https://github.com/juulSme/NoNoncense/blob/v2.0.0/lib/no_noncense/telemetry.ex#L2)

Events emitted while managing machine IDs. Nonce generation is never instrumented.

The module emits no events when the optional `:telemetry` dependency is unavailable.

## Lease operation spans

Lease acquisition, renewal, and release emit a span, where `operation` is `:acquire`,
`:renew`, or `:release`.

  * Start: `[:no_noncense, :machine_id, :lease, operation, :start]`
  * Stop: `[:no_noncense, :machine_id, :lease, operation, :stop]`

Start measurements:

  * `:system_time` - system time in native time units when the operation began.
  * `:monotonic_time` - monotonic time in native time units when the operation began.

Stop measurements:

  * `:duration` - elapsed monotonic time in native time units.
  * `:ttl_ms` - granted lease duration in milliseconds; present only for successful acquire
    and renew operations.

Both events include these metadata fields:

  * `:strategy` - the lease strategy module.
  * `source: :initial | :reacquire | :cache | :scheduled | :shutdown` - the operation's
    lifecycle path.

Stop events also include `result: :ok | :error | :retry | :lost`. `:retry` and `:lost`
distinguish strategy-confirmed transient failures from confirmed lease loss.

## Lease state events

### Retry scheduled

`[:no_noncense, :machine_id, :lease, :retry]` reports that a failed acquisition or renewal
will be retried.

Measurements:

  * `:attempt` - the retry attempt number.
  * `:delay_ms` - the delay before retrying, in milliseconds.

Metadata:

  * `operation: :acquire | :renew`.
  * `:reason` - the strategy's atom reason, or `:other` when the reason is not an atom.

### Lease lost

`[:no_noncense, :machine_id, :lease, :lost]` reports local expiry or a confirmed loss of the
lease.

Measurements:

  * `:remaining_ttl_ms` - milliseconds remaining in the locally tracked lease lifetime,
    clamped to zero.

Metadata:

  * `:reason` - the loss reason as an atom, or `:other` when the reason is not an atom.

## Conflict guard events

### Peer checked

`[:no_noncense, :machine_id, :conflict_guard, :peer_checked]` reports the result of comparing
this node's machine ID with a peer. It has no measurements.

Metadata:

  * `outcome: :conflict | :no_local_id | :match`.

### Conflict detected

`[:no_noncense, :machine_id, :conflict_guard, :conflict]` reports a duplicate machine ID. It
has no measurements.

Metadata:

  * `resolution: :local_node | :remote_node` - whether this node or the peer resolves the
    conflict.

---

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