Expand description
Declarative metric registry — the data-driven home for tier-2+ formulas.
A MetricDef pairs a CEL formula_cel with its spec (label / direction / …).
The default registry ships built-in derived metrics; a user adds their own by
editing config (e.g. comment_ratio = "sloc > 0.0 ? cloc / sloc * 100.0 : 0.0"). The Engine compiles each formula once, topologically orders them
by inter-metric dependencies, and evaluates them per node over the node’s
numeric attributes — the same engine will serve file and function units.
Scope: today the engine evaluates node-scope metrics and is used to
compute extra metrics on top of the built-in Rust derivation, so the
default pipeline (and its goldens) are untouched until this is wired in.
Graph-scope aggregates (scope = graph, percentiles, reducers) come later.
Structs§
- Engine
- A compiled, topologically ordered set of metric programs, split by scope:
node-scope (per node) and graph-scope (once over the whole node set, via the
agg(key, reducer, population)reducer function). - Metric
Def - One metric definition: a CEL formula plus the spec fields needed to emit it
as a first-class, sortable, delta-coloured attribute. Spec fields are
optional so a quick user formula needs only
formula_cel. - Populations
- The value populations an aggregate reduces over, per metric key. Two flavours
per the metric’s no-signal value (
omit_at):
Enums§
- Registry
Error - Errors surfaced when loading/compiling a registry — all caught at load time (not per node), so a bad user formula fails fast with a clear message.
- Scope
- Where a metric is evaluated: per node (default) or once over a collection.
Functions§
- apply_
to_ node - Apply the node-scope engine to one node: read its numeric attributes, compute
every registry metric, and write the results back, omitting each at its
omit_atexactly likecrate::write_metrics. Built-in attributes already present are used as inputs.