db

package
v1.54.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Observe

func Observe[T any](r *OperationRecorder, operation string, fn func() (T, error)) (T, error)

Observe runs fn, recording its duration under operation (e.g. "store.BatchUpsert") and a status of "ok" or "error" based on whether fn returned an error.

func ObserveErr

func ObserveErr(r *OperationRecorder, operation string, fn func() error) error

ObserveErr is Observe for operations that return only an error.

func RegisterPoolStats

func RegisterPoolStats(reg prometheus.Registerer, prefix string, pools map[string]any) error

RegisterPoolStats registers a collector exporting pool state, the configured bounds and acquisition counters for each named pool, under metric names beginning with prefix. Pools that don't implement PoolStatter (e.g. test fakes) are silently skipped.

Types

type OperationRecorder

type OperationRecorder struct {
	// contains filtered or unexported fields
}

OperationRecorder times repository/store-level calls into a histogram labeled "operation"/"status". The histogram is lazily created, so Observe/ObserveErr are safe to call even before Init has run.

func NewOperationRecorder

func NewOperationRecorder(name, help string) *OperationRecorder

NewOperationRecorder returns an independent recorder for a DB-operation-duration histogram with the given name/help.

func (*OperationRecorder) Init

Init registers r's histogram with reg. Call once, before serving traffic.

type PoolStats added in v1.44.0

type PoolStats = dbstats.PoolStats

PoolStats and PoolStatter are re-exported from pkg/dbstats so callers of this package need not import both. The definitions live there because the storage driver produces them and must not depend on Prometheus to do so.

type PoolStatter

type PoolStatter = dbstats.PoolStatter

PoolStats and PoolStatter are re-exported from pkg/dbstats so callers of this package need not import both. The definitions live there because the storage driver produces them and must not depend on Prometheus to do so.

Jump to

Keyboard shortcuts

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