OpentelemetryStatifier.Attributes (OpentelemetryStatifier v0.1.0)

Copy Markdown View Source

The uniform measurement/metadata-to-attribute mapping the design note (statifier-ex docs/opentelemetry.md, "Attribute mapping") fixes, applied to span events rather than re-decided per event name.

Every attribute lands under the statifier. namespace. Measurements are numbers by contract and pass through as numeric attributes of the same name. Metadata is mapped by shape:

  • :effect is never serialized - the raw struct is for in-VM consumers; a wire format is where "the struct rides verbatim" stops being cheap.
  • :location (a %Statifier.Parser.Location{}) flattens to statifier.source.line/statifier.source.column - the one place the bridge flattens a struct, because OTel attributes are scalar.
  • :configuration (already state-id strings by the ADR-0040 contract) becomes a sorted string-array attribute, bounded by the chart's state count.
  • :new_value, :prior_value, and :datamodel are the unbounded datamodel values: excluded unless the host opted in at setup with record_datamodel_values: true, and rendered with inspect/1 when it did - they are arbitrary terms, and inspect/1 is the only rendering that needs no per-type policy.
  • everything else is identity metadata: strings and integers pass through, atoms become strings, tuples (an owner, chart vocabulary of bounded shape) render with inspect/1, nil is omitted rather than encoded, and any other shape is dropped - a malformed value costs one attribute, never the event.

Summary

Functions

Maps one event's measurements and metadata into span-event attributes under the rules above, honoring config's record_datamodel_values opt-in.

Functions

span_event_attributes(measurements, metadata, config)

@spec span_event_attributes(map(), map(), OpentelemetryStatifier.Config.t()) :: map()

Maps one event's measurements and metadata into span-event attributes under the rules above, honoring config's record_datamodel_values opt-in.