View Source Zexbox.Metrics.Context (Zexbox v1.5.1)
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.
Summary
Functions
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.
Returns true if the current process has disabled metrics.
Re-enables metric writing for the current process.
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.
Functions
@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.
@spec disabled?() :: boolean()
Returns true if the current process has disabled metrics.
@spec enable_for_process() :: :ok
Re-enables metric writing for the current process.
@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.