instrument_metrics_exporter behaviour (instrument v1.0.0)
View SourceMetrics exporter manager for periodic metrics collection and export.
This module manages metrics exporters and handles periodic collection and export of metrics to registered backends.
Example Usage
%% Register console exporter for metrics
instrument_metrics_exporter:register(instrument_metrics_exporter_console:new()),
%% Register OTLP exporter
instrument_metrics_exporter:register(instrument_metrics_exporter_otlp:new(#{
endpoint => "http://localhost:4318"
})),
%% Metrics are collected and exported periodically
Summary
Functions
Behaviour callbacks for metrics exporters
Collects all metrics.
Triggers an immediate export.
Forces a flush of metrics to all exporters.
Lists all registered exporters.
Registers a metrics exporter.
Shuts down all exporters.
Starts the metrics exporter manager.
Unregisters a metrics exporter.
Types
-type data_point() :: #{attributes := map(), value := number() | histogram_value(), timestamp := integer()}.
-type metric_data() :: #{name := binary(), description := binary(), unit := binary(), type := counter | gauge | histogram, data_points := [data_point()]}.
Functions
Behaviour callbacks for metrics exporters
-spec collect() -> [metric_data()].
Collects all metrics.
-spec export() -> ok.
Triggers an immediate export.
-spec flush() -> ok.
Forces a flush of metrics to all exporters.
-spec list() -> [module()].
Lists all registered exporters.
Registers a metrics exporter.
-spec shutdown() -> ok.
Shuts down all exporters.
Starts the metrics exporter manager.
-spec unregister(module()) -> ok.
Unregisters a metrics exporter.