# `Zexbox.Metrics.Context`
[🔗](https://github.com/Intellection/zexbox/blob/main/lib/zexbox/metrics/context.ex#L1)

Per-process context for metrics: disable/enable and caller-chain checks.
Used by `Zexbox.Metrics.Client` to skip writes when the current process
or a parent (e.g. request process) has disabled metrics.

# `disable_for_process`

```elixir
@spec disable_for_process() :: :ok
```

Disables metric writing for the current process. Writes from this process
(and from tasks spawned with `Task.async` that have this process in `$callers`)
will be skipped until `enable_for_process/0` is called or the process exits.

# `disabled?`

```elixir
@spec disabled?() :: boolean()
```

Returns true if the current process has disabled metrics.

# `enable_for_process`

```elixir
@spec enable_for_process() :: :ok
```

Re-enables metric writing for the current process.

# `metrics_disabled?`

```elixir
@spec metrics_disabled?() :: boolean()
```

Returns true if metrics should be skipped for the current process: either
the process itself has disabled metrics, or any process in its caller chain
(`$callers` or `$ancestors`) has disabled metrics.

---

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