Documentation
¶
Overview ¶
Package metrics holds Dilion's Prometheus instruments: the HTTP surface, the database pools and the privacy workers.
Label cardinality is kept independent of the number of instances everywhere except the pool gauges. A multi-tenant deployment may serve thousands of instances (one per workspace), and an instance label on the request histograms would multiply every route by that number; a pool, on the other hand, is a per-instance resource whose exhaustion has to be traced to its instance. That label is `instance_id`, because Prometheus reserves `instance` for the scraped target and would rename ours.
Every method is safe on a nil *Metrics, so components built without metrics (tests, tools) need no guard.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics is the set of instruments one Server records into.
func New ¶
New registers the instruments. It fails only when the registry already holds collectors of the same names (two Servers sharing one registry).
func (*Metrics) Delivery ¶
Delivery records the outcome of one delivery attempt: completed, retry or dead.
func (*Metrics) Middleware ¶
Middleware records every request. Install it on the chi router itself (r.Use), so the matched route pattern is known once next returns — the pattern, not the URL path, is the label, so user ids and tokens in paths never become series — and ahead of middleware.Recoverer, so a panic is counted as the 500 the recoverer writes.
func (*Metrics) Registry ¶
func (m *Metrics) Registry() *prometheus.Registry
Registry is the registry the instruments live in.
type Options ¶
type Options struct {
// Registry receives every collector. nil creates a private registry that
// also carries the Go runtime and process collectors; a caller-supplied
// registry is assumed to have those already.
Registry *prometheus.Registry
// Version is reported by dilion_build_info.
Version string
// Pools feeds the dilion_db_pool_* gauges; nil reports none.
Pools PoolSource
}
Options configure New.