threshold

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package threshold implements FR-CLI-11: pass/fail thresholds on a run's own results, so a run can gate a CI pipeline.

A threshold is a name, a metric, an operator and a value, for example

fast-api: p95 < 300ms

It is judged once, against the finished run's numbers — the latency percentiles, error rate, request rate and counts VegaLoad itself measured. It never looks outside the run, and it produces a verdict (pass or fail) and nothing else.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllPassed

func AllPassed(rs []report.ThresholdResult) bool

AllPassed reports whether every result passed. It is true for an empty list, since a run with no thresholds has nothing to breach.

func Evaluate

func Evaluate(ts []Threshold, res *report.Result) []report.ThresholdResult

Evaluate judges every threshold against a finished run's result, in order. A run that completed no requests fails every threshold: with nothing measured, "p95 < 300ms" would otherwise pass trivially.

func MetricNames

func MetricNames() []string

MetricNames lists the metrics a threshold can use, for help text and error messages.

Types

type Threshold

type Threshold struct {
	Name     string
	Metric   string
	Operator string
	// Value is the canonical text of the limit: a duration such as
	// "300ms", or a plain number such as "0.01".
	Value string
	// contains filtered or unexported fields
}

Threshold is one parsed pass/fail threshold.

func LoadFile

func LoadFile(path string) ([]Threshold, error)

LoadFile reads thresholds from a JSON file (the -thresholds flag).

Three shapes are accepted, so a file can come straight from another command's output:

[{"name": "fast", "metric": "p95", "operator": "<", "value": "300ms"}]
{"thresholds": [ ...same list... ]}
{"latency_p95": "300ms", "error_rate": 0.015}

The last is what `vegaload diagnose -output json` suggests, under a "suggested_thresholds" key, which is also accepted. The suggested values are ceilings, so they become "<=" thresholds.

func Parse

func Parse(expr string) (Threshold, error)

Parse parses one threshold expression: an optional "name:" prefix, then metric, operator and value, e.g. "p95 < 300ms" or "fast-api: error_rate <= 1%".

func ParseAll

func ParseAll(exprs []string) ([]Threshold, error)

ParseAll parses several expressions, failing on the first bad one.

func ParseFile

func ParseFile(data []byte) ([]Threshold, error)

ParseFile parses the contents of a thresholds file. See LoadFile.

func (Threshold) Expression

func (t Threshold) Expression() string

Expression returns the threshold as text that Parse accepts again, including its name, e.g. "fast-api: p95 < 300ms". It is what other commands print as a ready-to-paste -threshold flag.

Jump to

Keyboard shortcuts

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