meter

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RecordCounterFunc         = RecordCounter
	RecordHistogramFunc       = RecordHistogram
	IncrementErrorCounterFunc = IncrementErrorCounter
	IncrementGaugeFunc        = IncrementGauge
	DecrementGaugeFunc        = DecrementGauge
	RecordLatencyFunc         = RecordLatency
	ObservableGaugeFunc       = InitObservableGauge
	ObservableGaugeValueFunc  = SetGaugeValue
	BatchCountersFunc         = AddBatchCounters
)

Functions

func AddBatchCounters

func AddBatchCounters(namedCounts map[string]int64, attrMap map[string]interface{})

AddBatchCounters allows batch incrementing of multiple counters by name, sharing the same attribute set for all.

func DecrementGauge

func DecrementGauge(name string)

DecrementGauge subtracts -1 from a named gauge.

func IncrementErrorCounter

func IncrementErrorCounter(name string, err error, attrMap map[string]interface{})

IncrementErrorCounter increments a named counter for errors. Automatically attaches error type and message to attributes.

func IncrementGauge

func IncrementGauge(name string, attrMap map[string]interface{}) error

IncrementGauge adds +1 to a named gauge.

func InitObservableGauge

func InitObservableGauge(name string, callback func(context.Context) float64) error

InitObservableGauge registers a gauge that observes values via a callback function. The callback is called automatically during OTEL collection/scrape.

func RecordCounter

func RecordCounter(name string, value int64, attrMap map[string]interface{})

RecordCounter increments a named counter metric by a specified value. Automatically initializes and caches the counter instrument.

func RecordHistogram

func RecordHistogram(name string, value float64, attrMap map[string]interface{})

RecordHistogram records a float64 value to a histogram metric. Useful for tracking things like latencies, sizes, durations, etc.

func RecordLatency

func RecordLatency(name string, start time.Time, attrMap map[string]interface{})

RecordLatency is a convenience function to record latency (in milliseconds) since the provided start time using a histogram.

func SetGaugeValue

func SetGaugeValue(name string, value int64, attrMap map[string]interface{}) error

SetGaugeValue manually sets the value for a named gauge metric. It stores the value internally and registers an observable gauge if needed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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