Converts Logger events to bounded OTLP records without performing I/O.
Body and attribute value limits measure encoded AnyValue bytes. Collection
traversal stops at the byte budget, 64 entries per container, or depth eight.
Long strings are truncated at a UTF-8 boundary. Oversized attribute keys and
attributes beyond max_attributes are omitted and counted; truncated values
remain attributes and are not counted as dropped. Internal Logger metadata is
intentionally excluded from the attribute set.
Summary
Functions
Validates record limits. Byte limits must be at least 32; count may be zero.
Builds a record using explicit observation time (nanoseconds) and correlation.
Correlation uses Logger's otel_trace_id, otel_span_id, and otel_trace_flags
metadata keys. A complete valid metadata pair takes precedence over context.
IDs accept fixed-width hex strings, raw bytes, or positive integers.
Malformed events return a tagged error without exposing their contents.
Maps Erlang Logger severity to OTLP severity; unknown levels are unspecified.
Functions
Validates record limits. Byte limits must be at least 32; count may be zero.
iex> {:ok, limits} = OtlpShipper.LogRecord.limits(max_attributes: 2)
iex> limits.max_attributes
2
@spec new(map(), map(), map(), non_neg_integer()) :: {:ok, map()} | {:error, :invalid_log_event}
Builds a record using explicit observation time (nanoseconds) and correlation.
Correlation uses Logger's otel_trace_id, otel_span_id, and otel_trace_flags
metadata keys. A complete valid metadata pair takes precedence over context.
IDs accept fixed-width hex strings, raw bytes, or positive integers.
Malformed events return a tagged error without exposing their contents.
iex> event = %{level: :info, msg: {:string, "ready"}, meta: %{time: 1}}
iex> {:ok, record} = OtlpShipper.LogRecord.new(event)
iex> {record.severity_number, record.body, record.time_unix_nano}
{9, %{value: {:string_value, "ready"}}, 1000}
@spec severity(atom()) :: non_neg_integer()
Maps Erlang Logger severity to OTLP severity; unknown levels are unspecified.
iex> OtlpShipper.LogRecord.severity(:notice)
10