hecate_plugin_metrics (hecate_sdk v0.6.2)

View Source

Plugin metrics facade.

Lightweight metrics using OTP counters (atomics-backed, lock-free) with an ETS registry. Each plugin gets its own counters reference with up to 64 metric slots.

Two metric types: counter — monotonically increasing (e.g. requests served) gauge — point-in-time value (e.g. last latency)

Plugins use macros from hecate_plugin.hrl: ?METRIC_INC(Name) — increment counter by 1 ?METRIC_ADD(Name, N) — increment counter by N ?METRIC_SET(Name, Val) — set gauge to Val

Summary

Functions

Remove all metrics for a plugin.

Increment a counter metric by N.

Set a gauge metric to Value.

Get all metrics for all plugins. Returns a list of maps with plugin, name, type, and value keys.

Get all metrics for a specific plugin.

Initialize metrics namespace for a plugin. Creates a counters reference with 64 slots. Safe to call multiple times (idempotent).

Functions

cleanup(PluginName)

-spec cleanup(binary()) -> ok.

Remove all metrics for a plugin.

counter(PluginName, MetricName, N)

-spec counter(binary(), binary(), integer()) -> ok.

Increment a counter metric by N.

gauge(PluginName, MetricName, Value)

-spec gauge(binary(), binary(), integer()) -> ok.

Set a gauge metric to Value.

get_all()

-spec get_all() -> [map()].

Get all metrics for all plugins. Returns a list of maps with plugin, name, type, and value keys.

get_plugin(PluginName)

-spec get_plugin(binary()) -> [map()].

Get all metrics for a specific plugin.

init(PluginName)

-spec init(binary()) -> ok.

Initialize metrics namespace for a plugin. Creates a counters reference with 64 slots. Safe to call multiple times (idempotent).