Documentation
¶
Overview ¶
Package prometheus records request counts and durations and serves them in the Prometheus text format, without depending on the Prometheus client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(metrics ...*Metrics) zinc.HandlerFunc
Handler serves the registry in Prometheus text format.
func New ¶
func New(configs ...Config) zinc.Middleware
New records each request's method, route pattern, status, and duration. Route labels use registered patterns, so path parameters cannot grow the number of series.
Types ¶
type Config ¶
type Config struct {
// Metrics is the registry to record into. Nil creates an isolated one,
// which Handler finds through the request context.
Metrics *Metrics
// Now supplies the clock; nil uses time.Now.
Now func() time.Time
}
Config controls request metric collection.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics stores in-process counters and duration sums. Route labels use registered patterns to avoid cardinality growth from path parameters.
func NewMetrics ¶
NewMetrics creates an isolated registry holding at most maxSeries series; zero means 10,000. Further new series are dropped and counted.