metrics

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetAccumulated added in v0.15.1

func ResetAccumulated()

ResetAccumulated clears shared values between tests.

Types

type Accumulator added in v0.15.1

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

Accumulator safely aggregates repeated operations by key.

func NewAccumulator added in v0.15.1

func NewAccumulator(recorder Recorder) *Accumulator

NewAccumulator writes shared aggregates to recorder; a nil recorder discards values.

func (*Accumulator) AddToSum added in v0.15.1

func (a *Accumulator) AddToSum(key string, delta int)

AddToSum adds delta to the running sum recorded under key.

func (*Accumulator) IsRecording added in v0.15.1

func (a *Accumulator) IsRecording() bool

IsRecording reports whether values written to this Accumulator reach a Recorder.

func (*Accumulator) KeepMaximum added in v0.15.1

func (a *Accumulator) KeepMaximum(key string, value int)

KeepMaximum records the largest value seen under key.

func (*Accumulator) RecordBool added in v0.15.1

func (a *Accumulator) RecordBool(key string, value bool)

RecordBool writes value without aggregation.

type Recorder

type Recorder interface {
	AddExtensionIntegerValue(key string, value int)
	AddExtensionStringValue(key string, value string)
	AddExtensionBoolValue(key string, value bool)
}

Recorder is satisfied by analytics.Analytics.

type RecorderFake

type RecorderFake struct {
	IntValues    map[string]int
	StringValues map[string]string
	BoolValues   map[string]bool
	// contains filtered or unexported fields
}

RecorderFake is a simple in-memory Recorder for use in tests. Like the production recorder it may be written to concurrently, so its values are mutex guarded.

func NewRecorderFake added in v0.15.1

func NewRecorderFake() *RecorderFake

NewRecorderFake returns an initialized recorder.

func (*RecorderFake) AddExtensionBoolValue

func (r *RecorderFake) AddExtensionBoolValue(key string, value bool)

func (*RecorderFake) AddExtensionIntegerValue

func (r *RecorderFake) AddExtensionIntegerValue(key string, value int)

func (*RecorderFake) AddExtensionStringValue

func (r *RecorderFake) AddExtensionStringValue(key string, value string)

Jump to

Keyboard shortcuts

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