This module is esponsible for setting up and supervising the metrics collection and telemetry. It attaches telemetry handlers for capturing metrics related to your Phoenix endpoints.
def start(_type, args) do
children = [{Zexbox.Metrics, []}]
Supervisor.start_link(children, opts)
end
Summary
Functions
Returns a specification to start this module under a supervisor.
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.
Initializes the supervisor with the required child processes.
Starts the metrics supervisor and attaches the controller metrics.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@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.
Use this in a Plug or elsewhere when you want to suppress metrics for a request (e.g. when a header indicates a test or health check).
@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.
Initializes the supervisor with the required child processes.
Examples
iex> Zexbox.Metrics.init(nil)
{:ok,
{%{intensity: 3, period: 5, strategy: :one_for_one, auto_shutdown: :never},
[
%{id: Zexbox.Metrics.ContextRegistry, ...},
%{
id: Zexbox.Metrics.Connection,
start: {Instream.Connection.Supervisor, :start_link, [Zexbox.Metrics.Connection]}
}
]}}
@spec start_link(args :: any()) :: Supervisor.on_start()
Starts the metrics supervisor and attaches the controller metrics.
Accepts an optional :enricher to customise the controller series before it
is written. See Zexbox.Metrics.ControllerSeriesEnricher.
children = [
{Zexbox.Metrics, enricher: {MyApp.MetricsEnricher, []}}
]An enricher can also be set via application env
(config :zexbox, :metrics_enricher, {MyApp.MetricsEnricher, []}); the
start_link/1 argument wins if both are present.
Examples
iex> Zexbox.Metrics.start_link(nil)
{:ok, #PID<0.123.0>}