instrument_log_exporter_otlp (instrument v1.0.0)
View SourceOTLP HTTP exporter for log records.
Exports log records to an OpenTelemetry Collector or compatible backend using the OTLP/HTTP protocol with JSON encoding.
Example Usage
%% Export to local collector
instrument_log_exporter:register(instrument_log_exporter_otlp:new(#{
endpoint => "http://localhost:4318"
})).
%% Export to remote collector with authentication
instrument_log_exporter:register(instrument_log_exporter_otlp:new(#{
endpoint => "https://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)
logs_path - API path (default: "/v1/logs")
Summary
Functions
Exports log records to the OTLP endpoint.
Forces a flush (handled by exporter manager).
Initializes the exporter.
Shuts down the exporter.
Creates a new OTLP log exporter configuration.
Functions
-spec exporter_export([#log_record{timestamp :: integer() | undefined, observed_timestamp :: integer() | undefined, severity_number :: integer() | undefined, severity_text :: binary() | undefined, body :: term(), attributes :: map(), trace_id :: <<_:128>> | undefined, span_id :: <<_:64>> | undefined, trace_flags :: 0 | 1 | undefined, resource :: #resource{attributes :: map(), schema_url :: binary() | undefined} | undefined, scope :: #scope{name :: binary(), version :: binary() | undefined, attributes :: map(), schema_url :: binary() | undefined} | undefined}], #state{endpoint :: binary(), logs_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}) -> {ok, #state{endpoint :: binary(), logs_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}} | {error, retryable, #state{endpoint :: binary(), logs_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}} | {error, permanent, #state{endpoint :: binary(), logs_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}}.
Exports log records to the OTLP endpoint.
-spec exporter_force_flush(#state{endpoint :: binary(), logs_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}) -> {ok, #state{endpoint :: binary(), logs_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}}.
Forces a flush (handled by exporter manager).
-spec exporter_init(map()) -> {ok, #state{endpoint :: binary(), logs_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}} | {error, term()}.
Initializes the exporter.
-spec exporter_shutdown(#state{endpoint :: binary(), logs_path :: binary(), headers :: [{binary(), binary()}], compression :: none | gzip, timeout :: pos_integer()}) -> ok.
Shuts down the exporter.
Creates a new OTLP log exporter configuration.