Help us shape the future of Go! Take the 2026 Go Developer Survey

prometheus

package
v0.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 8 Imported by: 0

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

func NewMetrics(maxSeries int) *Metrics

NewMetrics creates an isolated registry holding at most maxSeries series; zero means 10,000. Further new series are dropped and counted.

func (*Metrics) Observe

func (m *Metrics) Observe(method, route string, status int, duration time.Duration)

Observe records one completed request.

func (*Metrics) Text

func (m *Metrics) Text() string

Text returns a consistent snapshot in Prometheus exposition format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL