Skip to main content

Module attrs

Module attrs 

Source
Expand description

Shared attribute helpers used by every enrichment pass: numeric rounding, the f64 → AttrValue bridge, typed attribute reads, and the external-node predicate. This is a leaf module — it depends only on the plugin API, never on the crate root, so the enrichment passes can pull helpers from here without creating a submodule → crate-root back-edge.

Functions§

num_attr
Round a metric and pick the natural JSON scalar: an integral value becomes an Int (so 1.0 serializes as 1), otherwise a Float. This is the single bridge metric producers use before inserting into attrs.
round_sig3
Truncate to 3 significant digits (matching the historical sig3 serializer): values ≥ 1 are truncated to 3 decimals, values < 1 to 3 significant figures. Non-finite values collapse to 0 (JSON has no NaN/Inf).