instrument_metrics_exporter_otlp (instrument v1.0.0)
View SourceOTLP HTTP exporter for metrics.
Exports metrics to an OpenTelemetry Collector or compatible backend using the OTLP/HTTP protocol with JSON encoding.
Example Usage
%% Export to local collector
instrument_metrics_exporter:register(instrument_metrics_exporter_otlp:new(#{
endpoint => "http://localhost:4318"
})),
%% Export to remote collector with authentication
instrument_metrics_exporter:register(instrument_metrics_exporter_otlp:new(#{
endpoint => "https://otel-collector.example.com:4318",
headers => #{
<<"Authorization">> => <<"Bearer token123">>
},
compression => gzip
})),Configuration Options
endpoint- Base URL of the OTLP receiver (required)headers- Additional HTTP headers (default: #{})compression- Compression: none | gzip (default: none)timeout- Request timeout in ms (default: 10000)
Summary
Functions
Exports metrics to the OTLP endpoint.
Initializes the exporter.
Shuts down the exporter.
Creates a new OTLP exporter configuration.
Functions
-spec exporter_export([map()], #state{endpoint :: binary(), metrics_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}) -> {ok, #state{endpoint :: binary(), metrics_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}} | {error, retryable, #state{endpoint :: binary(), metrics_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}} | {error, permanent, #state{endpoint :: binary(), metrics_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}}.
Exports metrics to the OTLP endpoint.
-spec exporter_init(map()) -> {ok, #state{endpoint :: binary(), metrics_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}} | {error, term()}.
Initializes the exporter.
-spec exporter_shutdown(#state{endpoint :: binary(), metrics_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}) -> ok.
Shuts down the exporter.
Creates a new OTLP exporter configuration.