Documentation
¶
Overview ¶
Package threshold provides CEL-based evaluation of performance thresholds. Threshold expressions use a single `value` variable (float64) and must return a boolean. Example: "value >= 900".
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Registry = []Definition{
{Key: "busBandwidthGBps", Unit: "GB/s", Description: "Bus bandwidth (from BandwidthMeasurement)"},
{Key: "algBandwidthGBps", Unit: "GB/s", Description: "Algorithm bandwidth (from BandwidthMeasurement)"},
{Key: "goodputRatio", Unit: "ratio (0-1)", Description: "Goodput ratio (from GoodputMeasurement)"},
{Key: "avgTFLOPsPerGPU", Unit: "TFLOPS", Description: "Average TFLOPS per GPU (from GoodputMeasurement)"},
{Key: "avgStepTimeSec", Unit: "seconds", Description: "Average step time (from GoodputMeasurement)"},
}
Registry lists all known threshold keys. Unknown keys are rejected by ValidateKeys.
Functions ¶
func Evaluate ¶
Evaluate compiles and evaluates a CEL expression with the measured value. Returns true if the threshold is satisfied (expression returns true), false if violated (expression returns false). Returns an error if the expression fails to compile or evaluate.
func ValidateKeys ¶
ValidateKeys returns any keys in thresholds that are not in the Registry, sorted for deterministic messages.
func ValidateKeysError ¶
ValidateKeysError returns an error when thresholds contains keys that are not in the Registry. The error names each offending key and lists the valid keys, so a typo is diagnosed instead of silently disabling validation. Returns nil when every key is known.
Types ¶
type Definition ¶
type Definition struct {
// Key is the camelCase metric name with unit suffix.
Key string
// Unit is the human-readable unit for display (e.g., "GB/s", "seconds").
Unit string
// Description is a short help text for the metric.
Description string
}
Definition describes a known threshold key.
type Violation ¶
type Violation struct {
Key string
Expression string
Measured float64
Reason string // "ThresholdViolated", "InvalidThresholdExpression"
Message string
}
Violation describes a single threshold that was not met.
func EvaluateAll ¶
EvaluateAll checks all thresholds against measured values. Returns a list of violations (empty if all thresholds pass), sorted by key. Returns an error when thresholds contains a key that is not in the Registry: an unknown key can never be measured, so evaluating around it would silently skip validation. The error names the offending keys and lists the valid ones.