OtlpShipper.Value (otlp_shipper v0.1.1)

Copy Markdown View Source

Converts Elixir values into generated OTLP AnyValue message maps.

Invalid UTF-8 binaries use bytes_value; integers outside signed 64-bit range use strings. Atom keys and values become strings. Booleans retain their type. Conversion preserves values; ingress/truncation limits are enforced by callers.

Summary

Functions

Builds deterministic KeyValue messages with unique string keys.

Builds an AnyValue, recursively converting collections.

Functions

attributes(values)

@spec attributes(map()) :: [map()]

Builds deterministic KeyValue messages with unique string keys.

Atom/string collisions resolve to the string-keyed entry. Other key types use bounded inspection. Prefer strings or atoms for interoperable attributes.

iex> OtlpShipper.Value.attributes(%{count: 2})
[%{key: "count", value: %{value: {:int_value, 2}}}]

encode(value)

@spec encode(term()) :: map()

Builds an AnyValue, recursively converting collections.

iex> OtlpShipper.Value.encode(%{healthy: true})
%{value: {:kvlist_value, %{values: [%{key: "healthy", value: %{value: {:bool_value, true}}}]}}}

iex> OtlpShipper.Value.encode([1, "two"])
%{value: {:array_value, %{values: [%{value: {:int_value, 1}}, %{value: {:string_value, "two"}}]}}}