threshold

package
v0.1.0-rc.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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

View Source
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

func Evaluate(measured float64, expression string) (bool, error)

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

func ValidateKeys(thresholds map[string]string) []string

ValidateKeys returns any keys in thresholds that are not in the Registry.

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", "UnknownThresholdKey", "InvalidThresholdExpression"
	Message    string
}

Violation describes a single threshold that was not met.

func EvaluateAll

func EvaluateAll(thresholds map[string]string, measured map[string]float64) []Violation

EvaluateAll checks all thresholds against measured values. Returns a list of violations (empty if all thresholds pass).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL