WardrikEvents.Encoder.Value (wardrik_events v0.1.0-rc.1)

Copy Markdown

Encodes the values inside an event's data as JSON-ready maps with string keys.

Summary

Functions

Puts value under key. If it's longer than 64 KiB, cuts it short and sets "truncated".

Encodes a call's cost as whole micro-dollars. Returns nil if it isn't priced.

Encodes why something failed, as OpenTelemetry's error.type and a message.

Encodes any term as JSON. Maps get string keys, atoms become strings and structs become maps.

Encodes a message. Uses id, or the id in its metadata.

Encodes who did something.

Puts value under key, unless it's nil.

Encodes the tokens a model call read and wrote. Returns nil if there are none.

Functions

capped(map, key, value)

@spec capped(map(), String.t(), term()) :: map()

Puts value under key. If it's longer than 64 KiB, cuts it short and sets "truncated".

cost(arg1, source)

@spec cost(map(), String.t()) :: map() | nil

Encodes a call's cost as whole micro-dollars. Returns nil if it isn't priced.

error(exception)

@spec error(term()) :: map()

Encodes why something failed, as OpenTelemetry's error.type and a message.

json(principal)

@spec json(term()) :: term()

Encodes any term as JSON. Maps get string keys, atoms become strings and structs become maps.

message(message, id \\ nil)

@spec message(ReqLLM.Message.t(), String.t() | nil) :: map()

Encodes a message. Uses id, or the id in its metadata.

principal(arg1)

@spec principal(WardrikCore.Principal.t() | nil) :: map() | nil

Encodes who did something.

put(map, key, value)

@spec put(map(), String.t(), term()) :: map()

Puts value under key, unless it's nil.

usage(arg1)

@spec usage(map()) :: map() | nil

Encodes the tokens a model call read and wrote. Returns nil if there are none.