Documentation
¶
Overview ¶
Package runtimebudget reads runtime/metrics snapshots and compares them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnknownMetric means the metric name is not in runtime/metrics.All. ErrUnknownMetric = errors.New("runtimebudget: unknown metric") // ErrMetricMissing means a snapshot does not contain the requested metric. ErrMetricMissing = errors.New("runtimebudget: metric missing from snapshot") ErrMetricUnavailable = errors.New("runtimebudget: metric unavailable") // ErrKindMismatch means a value's kind differs from its runtime description. ErrKindMismatch = errors.New("runtimebudget: metric kind mismatch") // ErrUnsupportedKind means a newer or otherwise unsupported metric kind was seen. ErrUnsupportedKind = errors.New("runtimebudget: unsupported metric kind") // ErrNotCumulative means an operation requiring a cumulative metric was requested. ErrNotCumulative = errors.New("runtimebudget: metric is not cumulative") // ErrHistogramScalarDelta means a histogram was passed to scalar Delta or Rate. ErrHistogramScalarDelta = errors.New("runtimebudget: histogram needs bucket handling") // ErrHistogramRequired means HistogramDelta was passed a non-histogram metric. ErrHistogramRequired = errors.New("runtimebudget: metric is not a histogram") // ErrHistogramLayout means two histogram snapshots have different bucket boundaries. ErrHistogramLayout = errors.New("runtimebudget: histogram bucket layout mismatch") // ErrCounterReset means a cumulative value decreased between snapshots. ErrCounterReset = errors.New("runtimebudget: cumulative metric decreased") // ErrInvalidInterval means the current snapshot is not after the previous one. ErrInvalidInterval = errors.New("runtimebudget: snapshot interval must be positive") // ErrInvalidBudget means a budget limit is NaN or infinite. ErrInvalidBudget = errors.New("runtimebudget: budget limit must be finite") // ErrHistogramBudget means a histogram cannot be checked as one scalar value. ErrHistogramBudget = errors.New("runtimebudget: histogram budget needs bucket handling") // ErrBudgetExceeded means at least one budget was exceeded. ErrBudgetExceeded = errors.New("runtimebudget: budget exceeded") )
Functions ¶
Types ¶
type Histogram ¶
Histogram is an explicit bucketed metric value. Counts[i] covers [Buckets[i], Buckets[i+1]).
type Report ¶
Report contains budget violations and metrics that could not be checked.
func Check ¶
Check evaluates maximum numeric budgets for non-cumulative scalar metrics. The returned report is deterministic by metric name. Use report.Err() when the caller wants violations and evaluation issues as an error.
type ReportError ¶
type ReportError struct {
Report Report
}
ReportError is returned by Report.Err when a check has violations or issues.
func (*ReportError) Error ¶
func (e *ReportError) Error() string
func (*ReportError) Unwrap ¶
func (e *ReportError) Unwrap() []error
Unwrap makes errors.Is useful for both violations and evaluation issues.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot is an immutable copy of selected runtime metrics at one point in time. The snapshot's histogram slices are copied, so a later runtime/metrics.Read does not change this snapshot.
func Read ¶
Read reads the named metrics. With no names, it reads every metric currently returned by runtime/metrics.All. Unknown names are retained with KindBad.
func ReadAll ¶
func ReadAll() Snapshot
ReadAll reads every metric currently returned by runtime/metrics.All.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is a kind-tagged runtime metric value.
func Delta ¶
Delta returns the scalar increase of a cumulative metric. Histograms are intentionally rejected; use HistogramDelta for their bucket counts.