# `ApifyClient.Telemetry`
[🔗](https://github.com/social-growth-studio/apify-client-ex/blob/v1.0.0/lib/apify_client/telemetry.ex#L1)

Bounded `:telemetry` lifecycle events for Apify API operations.

The client depends only on standard Elixir `:telemetry`. Applications may
translate these events into traces, metrics, logs, or another observability
backend.

## Events

* `[:apify_client, :request, :start]` is emitted before an HTTP request.
  Measurements contain `:system_time` and `:count`.
* `[:apify_client, :request, :stop]` is emitted for successful 2xx responses.
  Measurements contain `:duration` in native time units and `:count`.
* `[:apify_client, :request, :exception]` is emitted for API, transport,
  streaming, cancellation, and unexpected errors. Measurements contain
  `:duration` in native time units and `:count`.

Every event includes a unique opaque `:telemetry_ref`, plus only bounded
`:method` and `:resource` values. `:telemetry_ref` correlates a lifecycle's
start and completion events and must not be used as a metric label or span
attribute. `:resource` is restricted to fixed top-level Apify resource names (or
`"other"`), so identifiers, query parameters, API tokens, arbitrary URLs,
and error messages never become metric labels. Completion events add
`:status_code` and `:outcome`; non-successful completions add a bounded
`:error_type`.

# `lifecycle`

```elixir
@type lifecycle() :: %{
  completion: :atomics.atomics_ref(),
  metadata: request_metadata(),
  start_time: integer()
}
```

# `request_metadata`

```elixir
@type request_metadata() :: %{
  method: :delete | :get | :head | :patch | :post | :put,
  resource: String.t(),
  telemetry_ref: reference()
}
```

---

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