# `ExMqtt.Telemetry`
[🔗](https://github.com/Ultraluv/ex_mqtt_uv/blob/v0.1.0/lib/ex_mqtt/telemetry.ex#L1)

Telemetry instrumentation for `ExMqtt` using `:telemetry ~> 1.4`.

## Events

### Connection Lifecycle (`ExMqtt.Connection`)
- `[:ex_mqtt, :connection, :connect, :start]` - emitted when opening transport & sending CONNECT
- `[:ex_mqtt, :connection, :connected]` - emitted when CONNACK `:success` is received
- `[:ex_mqtt, :connection, :disconnected]` - emitted when the connection closes or is refused
- `[:ex_mqtt, :connection, :reconnect, :scheduled]` - emitted when an exponential-backoff reconnect timer is scheduled

### Messaging & Subscriptions
- `[:ex_mqtt, :publish, :sent]` - emitted when an outbound PUBLISH is transmitted
- `[:ex_mqtt, :publish, :received]` - emitted when an inbound PUBLISH is delivered
- `[:ex_mqtt, :subscribe, :stop]` - emitted when SUBACK is received
- `[:ex_mqtt, :unsubscribe, :stop]` - emitted when UNSUBACK is received

### Packets & Enhanced Authentication (MQTT 5.0)
- `[:ex_mqtt, :packet, :sent]` - emitted for every encoded MQTT control packet sent over the wire
- `[:ex_mqtt, :packet, :received]` - emitted for every decoded MQTT control packet received
- `[:ex_mqtt, :auth, :sent]` - emitted when an outbound MQTT 5.0 AUTH packet is sent
- `[:ex_mqtt, :auth, :received]` - emitted when an inbound MQTT 5.0 AUTH packet is received

# `attach_default_logger`

```elixir
@spec attach_default_logger(keyword()) :: :ok | {:error, :already_exists}
```

Attaches a default `Logger`-based telemetry handler for debugging and observability.

# `detach_default_logger`

```elixir
@spec detach_default_logger(String.t()) :: :ok | {:error, :not_found}
```

Detaches the default telemetry logger handler.

# `events`

```elixir
@spec events() :: [[atom()]]
```

Returns the list of all telemetry event names emitted by `ExMqtt`.

# `execute`

```elixir
@spec execute([atom()], map(), map()) :: :ok
```

Executes a telemetry event with measurements and metadata.

# `span`

```elixir
@spec span([atom()], map(), (-&gt; {term(), map()})) :: term()
```

Wraps an operation in `:telemetry.span/3`.

---

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