metrics

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package metrics provides abstract metrics interfaces that allow pluggable instrumentation backends (Prometheus, StatsD, etc.) without coupling the core packages to any specific implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter interface {
	// Inc increments the counter by 1.
	Inc()
	// Add increments the counter by delta. delta must be >= 0.
	Add(delta float64)
}

Counter is a monotonically increasing metric.

func NopCounter

func NopCounter() Counter

NopCounter returns a no-op Counter.

type Gauge

type Gauge interface {
	// Set sets the gauge to value.
	Set(value float64)
	// Inc increments the gauge by 1.
	Inc()
	// Dec decrements the gauge by 1.
	Dec()
	// Add adds delta to the gauge. delta can be negative.
	Add(delta float64)
}

Gauge is a metric that can go up and down.

func NopGauge

func NopGauge() Gauge

NopGauge returns a no-op Gauge.

type Histogram

type Histogram interface {
	// Observe adds a single observation to the histogram.
	Observe(value float64)
}

Histogram samples observations (e.g., request latencies) and counts them in configurable buckets.

func NopHistogram

func NopHistogram() Histogram

NopHistogram returns a no-op Histogram.

type Timer

type Timer interface {
	// ObserveDuration records the elapsed time since the timer was created.
	ObserveDuration()
}

Timer measures the duration of an operation. Call ObserveDuration when the operation completes to record the elapsed time.

func NopTimer

func NopTimer() Timer

NopTimer returns a no-op Timer.

type TimerFunc

type TimerFunc func() Timer

TimerFunc is a function that creates a new Timer. This allows deferred timing patterns like: defer metrics.StoreLoadDuration("user").ObserveDuration()

func NopTimerFunc

func NopTimerFunc() TimerFunc

NopTimerFunc returns a TimerFunc that always returns a no-op Timer.

Jump to

Keyboard shortcuts

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