package lazymetrics

import "golazy.dev/lazytelemetry/lazymetrics"

Package lazymetrics provides lightweight metric helpers for GoLazy telemetry.

Functions

func WithLabels

WithLabels attaches metric labels to ctx.

func WithLabels(ctx context.Context, labels Labels) context.Context

func WithRequestLabels

WithRequestLabels attaches request-scoped metric labels to ctx. Descendant WithLabels calls merge into the same label set, which lets outer request middleware record labels discovered later in routing.

func WithRequestLabels(ctx context.Context, labels Labels) context.Context

func WritePrometheus

WritePrometheus writes snapshot using the Prometheus text exposition format.

func WritePrometheus(w io.Writer, snapshot Snapshot) error

Types

type Registry

Registry stores in-memory metrics.

type Registry struct {
	// contains filtered or unexported fields
}
func NewRegistry

NewRegistry creates an empty metric registry.

func NewRegistry() *Registry
func (r *Registry) NewCounter

NewCounter creates a counter vector.

func (r *Registry) NewCounter(name string, labelNames ...string) *CounterVec
func (r *Registry) NewGauge

NewGauge creates a gauge vector.

func (r *Registry) NewGauge(name string, labelNames ...string) *GaugeVec
func (r *Registry) NewHistogram

NewHistogram creates a histogram vector.

func (r *Registry) NewHistogram(name string, labelNames ...string) *HistogramVec
func (r *Registry) Snapshot

Snapshot returns a copy of all registry values.

func (r *Registry) Snapshot() Snapshot