Documentation
¶
Overview ¶
Package stats defines the self-describing statistics payload a service can expose through its `stats` invocation, and the Reporter capability a driver implements to produce it.
A service whose manager implements Reporter registers the "stats" invocation; the stats prometheus collector (pkg/prom/stats) discovers those services through the registry and turns their payloads into metrics. The payload fully describes its metrics (names, kinds, labels), so new services need no collector changes.
Counters derived from creation-time row counts are monotonic as long as rows are soft-deleted; a hard-delete cleanup shows up in Prometheus as a counter reset.
Index ¶
Constants ¶
const ( KindGauge = "gauge" KindCounter = "counter" )
Metric kinds.
const Invocation = "stats"
Invocation is the conventional invocation name under which services expose their statistics.
Variables ¶
This section is empty.
Functions ¶
func NewInvokeSet ¶
NewInvokeSet returns an invocation set exposing the "stats" invocation when the manager implements Reporter, and an empty set otherwise. A service embeds the returned set to become invokable, so the capability of its driver decides whether it advertises statistics.
Types ¶
type Metric ¶
type Metric struct {
Name string `json:"name"`
Help string `json:"help,omitempty"`
// Kind is KindGauge or KindCounter.
Kind string `json:"kind"`
// Samples are plain samples.
Samples []Sample `json:"samples,omitempty"`
// OwnerSamples are per-owner aggregates. The collector folds them by
// the owner attributes available at the site (or into plain totals);
// they are never exposed as per-owner series.
OwnerSamples []OwnerSample `json:"owner_samples,omitempty"`
}
Metric is one metric family. Name carries the subject only — the collector prefixes the configured namespace and appends the Prometheus-conventional `_total` suffix to counters.
type OwnerSample ¶
type OwnerSample struct {
Owner string `json:"owner"`
Labels map[string]string `json:"labels,omitempty"`
Value float64 `json:"value"`
}
OwnerSample is one per-owner value with an optional label set.
type Payload ¶
type Payload struct {
// Metrics are the self-described metric families.
Metrics []Metric `json:"metrics"`
}
Payload is the return value of a "stats" invocation.