Documentation ¶
Overview ¶
Package stats defines statistics tracker.
Index ¶
- func AddKeysAndValues(ctx context.Context, keysAndValues ...string) context.Context
- func KeysAndValues(ctx context.Context) []string
- type Adder
- type AdderFunc
- type NoOp
- type Setter
- type SetterFunc
- type Tracker
- type TrackerMock
- func (t *TrackerMock) Add(_ context.Context, name string, increment float64, labels ...string)
- func (t *TrackerMock) Int(name string, labels ...string) int
- func (t *TrackerMock) LabeledValues() map[string]float64
- func (t *TrackerMock) Metrics() string
- func (t *TrackerMock) Set(_ context.Context, name string, absolute float64, labels ...string)
- func (t *TrackerMock) StatsTracker() Tracker
- func (t *TrackerMock) Value(name string, labels ...string) float64
- func (t *TrackerMock) Values() map[string]float64
- type TrackerProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddKeysAndValues ¶
AddKeysAndValues returns context with added key-value pairs. If key-value pairs exist in parent context already, new pairs are appended.
func KeysAndValues ¶
KeysAndValues returns key-pairs found in context or nil.
Types ¶
type Adder ¶
type Adder interface { // Add collects additional or observable value. Add(ctx context.Context, name string, increment float64, labelsAndValues ...string) }
Adder defines incremental metric collector.
type NoOp ¶
type NoOp struct{}
NoOp is a stats tracker stub.
type Setter ¶
type Setter interface { // Set collects absolute value, e.g. number of goroutines. Set(ctx context.Context, name string, absolute float64, labelsAndValues ...string) }
Setter defines absolute value collector.
type SetterFunc ¶
SetterFunc implements Setter.
type TrackerMock ¶
type TrackerMock struct {
// contains filtered or unexported fields
}
TrackerMock can collect stats for tests with labels ignored.
func (*TrackerMock) Int ¶
func (t *TrackerMock) Int(name string, labels ...string) int
Int returns collected value as integer by name.
func (*TrackerMock) LabeledValues ¶ added in v0.1.2
func (t *TrackerMock) LabeledValues() map[string]float64
LabeledValues returns collected labeled values as a map.
func (*TrackerMock) Metrics ¶ added in v0.1.2
func (t *TrackerMock) Metrics() string
Metrics returns collected values in Prometheus format.
func (*TrackerMock) StatsTracker ¶
func (t *TrackerMock) StatsTracker() Tracker
StatsTracker is a provider.
func (*TrackerMock) Value ¶
func (t *TrackerMock) Value(name string, labels ...string) float64
Value returns collected value by name.
func (*TrackerMock) Values ¶
func (t *TrackerMock) Values() map[string]float64
Values returns collected summarized values as a map.
type TrackerProvider ¶
type TrackerProvider interface {
StatsTracker() Tracker
}
TrackerProvider defines service locator interface.