shigoto_metrics (shigoto_metrics v0.1.4)
View SourcePrometheus metrics collectors for shigoto.
Declares Prometheus metrics for the shigoto telemetry surface (see the
Telemetry contract) and attaches
telemetry handlers that translate events into counter / histogram updates.
This package has no web dependency and stands up no listener of its own. Serve the scrape output from your application's existing web layer. For a Nova app (the shigoto ecosystem's web framework), a one-line controller does it:
-module(metrics_controller).
-export([index/1]).
index(_Req) ->
{status, 200, #{~"content-type" => ~"text/plain; version=0.0.4"},
shigoto_metrics:scrape()}.then route {"/metrics", fun metrics_controller:index/1, #{methods => [get]}}.
If you are not on Nova, mount prometheus_cowboy2_handler on your own Cowboy
listener, or return scrape/0 from whatever handler you already run. Enabling
metrics is just:
{ok, _} = application:ensure_all_started(shigoto_metrics).auto_setup (default true) declares the metrics and attaches the handlers at
boot; set it to false to call setup/0 yourself.
Summary
Functions
-spec scrape() -> binary().
Render the current metrics in Prometheus text exposition format. Return this
from your /metrics handler with content type
text/plain; version=0.0.4.
-spec setup() -> ok.
Declare metrics and attach telemetry handlers. Idempotent.