pub struct MetricDef {Show 15 fields
pub formula_cel: String,
pub scope: Scope,
pub value_type: String,
pub label: Option<String>,
pub name: Option<String>,
pub short: Option<String>,
pub description: Option<String>,
pub remediation: Option<String>,
pub formula_pretty: Option<String>,
pub formula_js: Option<String>,
pub direction: Option<String>,
pub group: Option<String>,
pub omit_at: f64,
pub warning: Option<f64>,
pub info: Option<f64>,
}Expand description
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.
Fields§
§formula_cel: StringCEL expression over other metric keys + the registered math functions.
scope: Scope§value_type: String§label: Option<String>§name: Option<String>§short: Option<String>§description: Option<String>§remediation: Option<String>How to fix a breach — the fix line in check diagnostics.
formula_pretty: Option<String>Human-readable formula shown in the viewer (display only).
formula_js: Option<String>JS expression the viewer re-runs with the node’s values to show the live
“formula = numbers” line. When omitted, a node-scope metric falls back to
its CEL formula_cel — valid JS for plain arithmetic / ternaries; if it
uses CEL-only host functions (log2, pow, …) the viewer simply skips the
line. Set formula_js explicitly to control it.
direction: Option<String>lower_better / higher_better.
group: Option<String>§omit_at: f64No-signal value at which the metric is omitted (the registry [defaults]
omit_at when unset).
warning: Option<f64>Two-tier severity thresholds (the warning / info limits the scorecard
and viewer badge against, like a built-in metric). When either is set the
metric carries a Thresholds in its spec; the other tier falls back to
it. Distinct from the [rules.thresholds.file] single-tier check gate.
info: Option<f64>Implementations§
Source§impl MetricDef
impl MetricDef
Sourcepub fn to_attribute_spec(&self) -> AttributeSpec
pub fn to_attribute_spec(&self) -> AttributeSpec
The viewer-facing AttributeSpec for this metric, so a config-defined
metric renders as a named, sortable, delta-coloured column like any
built-in — including the live “formula = numbers” tooltip line, driven by
formula_js (defaulted from the CEL formula_cel for node-scope metrics).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for MetricDef
impl<'de> Deserialize<'de> for MetricDef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for MetricDef
impl RefUnwindSafe for MetricDef
impl Send for MetricDef
impl Sync for MetricDef
impl Unpin for MetricDef
impl UnsafeUnpin for MetricDef
impl UnwindSafe for MetricDef
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer