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 WritePrometheus

WritePrometheus writes snapshot using the Prometheus text exposition format.

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

Types

type Labels

Labels stores low-cardinality metric labels.

type Labels map[string]string
func LabelsFromContext

LabelsFromContext returns metric labels attached to ctx.

func LabelsFromContext(ctx context.Context) Labels

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