Documentation
¶
Overview ¶
Package metrics is Atlas's Prometheus exposition: an owned registry, the naming conventions every Atlas metric follows, and the HTTP handler that serves them (ADR-0142).
Why an owned registry ¶
Nothing here touches prometheus.DefaultRegisterer. A package-level default is global mutable state shared with every library in the process: it makes what an operator scrapes depend on the import graph, and it makes tests order-dependent. An owned registry means the exported set is exactly what Atlas registered, and a test can scrape a server without reaching through a global. Go-runtime and process collectors are opt-in for the same reason — what appears at /metrics should be a decision.
The two rules ¶
**Bounded cardinality.** A label's values must be fixed by the code, not by the data. Never label by instance key, job key, correlation key, process id, element id, URL, or any other value an operator or a model can invent: one such label turns a metric into unboundedly many time series. A per-definition breakdown is a query over the API, which can paginate; a scrape target can only fall over.
**No allocation on the hot path.** A labeled metric is resolved to its concrete child once, when the registry is built, and stored as a field; the engine's batch loop then touches a prometheus.Counter, never a *Vec — no map lookup, no label slice, no allocation (invariant I1). The proof is a benchmark, not a review.
Index ¶
Constants ¶
const Namespace = "atlas"
Namespace prefixes every Atlas metric name, so a scrape shared with other exporters stays unambiguous.
Variables ¶
This section is empty.
Functions ¶
func BuildInfo ¶
func BuildInfo(version, revision string) prometheus.Collector
BuildInfo is the conventional single-series metric carrying the running build, so a dashboard can correlate a graph with the binary that produced it. The label values are fixed at construction — one series, forever.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry owns the Prometheus registry Atlas exports and the handler that serves it.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry builds an empty registry. It deliberately registers no Go-runtime or process collectors: a caller that wants them adds them explicitly.
func (*Registry) Gather ¶
func (r *Registry) Gather() ([]*dto.MetricFamily, error)
Gather returns the current metric families, for tests and for callers that want the numbers without going through HTTP.