spec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package spec is what a vis declaration means, in one place: which measures are latencies, and which vis types hold latencies. The library's checks, vis gen and vis vet all read it, so they can't disagree; a test in vis ties the library's own measures to it.

Index

Constants

View Source
const LevelTrace = slog.LevelDebug - 4

LevelTrace is the level vis calls TRACE. slog has none; DEBUG-4 is the usual one (Ollama's, among others), so a range down to it reads as TRACE..ERROR instead of an offset nobody chose.

View Source
const MinDurationStep = time.Microsecond

MinDurationStep is the smallest step or drift that reads as meant on a Duration knob: below it, a bare number was almost surely meant in another unit, since a Duration knob counts nanoseconds.

View Source
const RouteP99 = Latency

RouteP99 is a route's p99, vis.RouteP99: a latency.

Variables

View Source
var Measures = []Measure{
	{"sched.p99", "SchedP99", Latency},
	{"gc.cpu", "GCCPU", Number},
	{"cpu.throttled", "CPUThrottled", Number},
	{"cpu.used", "CPUUsed", Number},
	{"goroutines", "Goroutines", Number},
}

Measures are vis's ready-made measures.

Functions

func Cut

func Cut(from, to int64) int64

Cut is how much a step from from to to cuts, in whole percent.

func LevelName

func LevelName(l slog.Level) string

LevelName is how people and agents see a log level: TRACE, DEBUG, INFO, WARN or ERROR, with an offset for one in between, as slog writes it.

func Lurch

func Lurch(def, lo, step, drift int64) (from, to int64, ok bool)

Lurch is the first step of a rule's fixed step that cuts its knob by more than half: the value before and after it, as the rule steps from the knob's default def toward the end of its reach (drift, by default four steps, and no lower than lo). Sizes, counts and concurrency respond to ratios, so a fixed step gets harsher near the bottom of the range: -16 takes 64 to 48 but 16 to 1. A step that grows the knob, or a knob whose range reaches below zero, where a value isn't a size, never lurches.

func ParseLevel

func ParseLevel(s string) (slog.Level, error)

ParseLevel reads a level by name, in any case: trace, debug, info, warn or error, or one with an offset such as debug+2 or trace-1.

Types

type Kind

type Kind int

Kind is what a measure or a threshold is: a latency (milliseconds, written as a time.Duration) or a plain number.

const (
	Unknown Kind = iota
	Latency
	Number
)

func TypeKind

func TypeKind(visType string) Kind

TypeKind is what a vis type's values are, as a measure or a threshold: a Latency gauge and a Duration knob are latencies; a Gauge and an Int knob are numbers.

func (Kind) String

func (k Kind) String() string

type Measure

type Measure struct {
	Name string // as a rule's when= names it: sched.p99
	Var  string // the vis variable: SchedP99
	Kind Kind
}

Measure is one of vis's ready-made measures.

func MeasureNamed

func MeasureNamed(name string) (Measure, bool)

MeasureNamed is the ready-made measure a rule's when= names, if any.

func MeasureVar

func MeasureVar(v string) (Measure, bool)

MeasureVar is the ready-made measure a vis variable holds, if any.

Jump to

Keyboard shortcuts

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