Expand description
Helpers for OTel attribute / AnyValue → JSONB translation
Converts OTel KeyValue arrays + scalar AnyValue instances to JSONB bytes.
Mapping follows the plan’s “Attribute value encoding” table:
- string → JSON string
- int / double / bool → JSON number / bool
- bytes → base64-encoded string (existing properties consumers expect text)
- array / kvlist → recursive JSON
The output is a JSONB-encoded {key → value} blob suitable for the
properties columns across log_entries, measures, and otel_spans.
Functions§
- any_
value_ to_ jsonb - Converts an
AnyValueto ajsonb::Value. Recursively handles arrays and kvlists. - any_
value_ to_ string - Renders
AnyValueto a flat string for fields that need a textual form (e.g., themsgcolumn when an OTel log body is structured). - attrs_
to_ jsonb - Serializes a flat
(key → value)map (with optional extra entries layered on top) to JSONB bytes. Output ordering is alphabetical, matchingserialize_properties_to_jsonb. - scope_
extras - Builds the per-row
otel.scope.*properties (name,version,attr.*,schema_url) that ride alongside row attributes in the JSONBpropertiescolumn. Skips empty fields so absent scopes don’t pollute the output. - severity_
number_ to_ level - Maps OTel
severity_number(1–24) to micromegasLevel(1–6). - to_
jsonb_ bytes - Encodes a
JsonbValueto its on-wire JSONB bytes.