Documentation
¶
Index ¶
- func Observe[T any](r *OperationRecorder, operation string, fn func() (T, error)) (T, error)
- func ObserveErr(r *OperationRecorder, operation string, fn func() error) error
- func RegisterPoolStats(reg prometheus.Registerer, prefix string, pools map[string]any) error
- type OperationRecorder
- type PoolStats
- type PoolStatter
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 ¶
func (r *OperationRecorder) Init(reg prometheus.Registerer) error
Init registers r's histogram with reg. Call once, before serving traffic.
type PoolStats ¶ added in v1.44.0
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.