mock

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter struct {
	Name  string
	Tags  map[string]string
	Value *atomic.Int64
}

Counter tracks monotonically increasing value.

func (*Counter) Add

func (c *Counter) Add(delta int64)

Add adds delta to the counter. Delta must be >=0.

func (*Counter) Inc

func (c *Counter) Inc()

Inc increments counter by 1.

type CounterVec

type CounterVec struct {
	Vec MetricsVector
}

CounterVec stores counters and implements metrics.CounterVec interface

func (*CounterVec) Reset

func (v *CounterVec) Reset()

Reset deletes all metrics in this vector.

func (*CounterVec) With

func (v *CounterVec) With(tags map[string]string) metrics.Counter

With creates new or returns existing counter with given tags from vector. It will panic if tags keys set is not equal to vector labels.

type DurationHistogramVec

type DurationHistogramVec struct {
	Vec MetricsVector
}

DurationHistogramVec stores duration histograms and implements metrics.TimerVec interface

func (*DurationHistogramVec) Reset

func (v *DurationHistogramVec) Reset()

Reset deletes all metrics in this vector.

func (*DurationHistogramVec) With

func (v *DurationHistogramVec) With(tags map[string]string) metrics.Timer

With creates new or returns existing duration histogram with given tags from vector. It will panic if tags keys set is not equal to vector labels.

type FuncCounter

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

func (FuncCounter) Function

func (c FuncCounter) Function() func() int64

type FuncGauge

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

func (FuncGauge) Function

func (g FuncGauge) Function() func() float64

type FuncIntGauge

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

func (FuncIntGauge) Function

func (g FuncIntGauge) Function() func() int64

type Gauge

type Gauge struct {
	Name  string
	Tags  map[string]string
	Value *atomic.Float64
}

Gauge tracks single float64 value.

func (*Gauge) Add

func (g *Gauge) Add(value float64)

func (*Gauge) Set

func (g *Gauge) Set(value float64)

type GaugeVec

type GaugeVec struct {
	Vec MetricsVector
}

GaugeVec stores gauges and implements metrics.GaugeVec interface

func (*GaugeVec) Reset

func (v *GaugeVec) Reset()

Reset deletes all metrics in this vector.

func (*GaugeVec) With

func (v *GaugeVec) With(tags map[string]string) metrics.Gauge

With creates new or returns existing gauge with given tags from vector. It will panic if tags keys set is not equal to vector labels.

type Histogram

type Histogram struct {
	Name         string
	Tags         map[string]string
	BucketBounds []float64
	BucketValues []int64
	InfValue     *atomic.Int64
	// contains filtered or unexported fields
}

func (*Histogram) RecordDuration

func (h *Histogram) RecordDuration(value time.Duration)

func (*Histogram) RecordValue

func (h *Histogram) RecordValue(value float64)

type HistogramVec

type HistogramVec struct {
	Vec MetricsVector
}

HistogramVec stores histograms and implements metrics.HistogramVec interface

func (*HistogramVec) Reset

func (v *HistogramVec) Reset()

Reset deletes all metrics in this vector.

func (*HistogramVec) With

func (v *HistogramVec) With(tags map[string]string) metrics.Histogram

With creates new or returns existing histogram with given tags from vector. It will panic if tags keys set is not equal to vector labels.

type IntGauge

type IntGauge struct {
	Name  string
	Tags  map[string]string
	Value *atomic.Int64
}

IntGauge tracks single int64 value.

func (*IntGauge) Add

func (g *IntGauge) Add(value int64)

func (*IntGauge) Set

func (g *IntGauge) Set(value int64)

type IntGaugeVec

type IntGaugeVec struct {
	Vec MetricsVector
}

IntGaugeVec stores gauges and implements metrics.IntGaugeVec interface

func (*IntGaugeVec) Reset

func (v *IntGaugeVec) Reset()

Reset deletes all metrics in this vector.

func (*IntGaugeVec) With

func (v *IntGaugeVec) With(tags map[string]string) metrics.IntGauge

With creates new or returns existing gauge with given tags from vector. It will panic if tags keys set is not equal to vector labels.

type MetricsVector

type MetricsVector interface {
	With(map[string]string) interface{}

	// Reset deletes all metrics in vector.
	Reset()
}

type Registry

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

func NewRegistry

func NewRegistry(opts *RegistryOpts) *Registry

func (Registry) ComposeName

func (r Registry) ComposeName(parts ...string) string

func (Registry) Counter

func (r Registry) Counter(name string) metrics.Counter

func (*Registry) CounterVec

func (r *Registry) CounterVec(name string, labels []string) metrics.CounterVec

CounterVec creates a new counters vector with given metric name and partitioned by the given label names.

func (Registry) DurationHistogram

func (r Registry) DurationHistogram(name string, buckets metrics.DurationBuckets) metrics.Timer

func (*Registry) DurationHistogramVec

func (r *Registry) DurationHistogramVec(name string, buckets metrics.DurationBuckets, labels []string) metrics.TimerVec

DurationHistogramVec creates a new duration histograms vector with given metric name and buckets and partitioned by the given label names.

func (Registry) FuncCounter

func (r Registry) FuncCounter(name string, function func() int64) metrics.FuncCounter

func (Registry) FuncGauge

func (r Registry) FuncGauge(name string, function func() float64) metrics.FuncGauge

func (*Registry) FuncIntGauge

func (r *Registry) FuncIntGauge(name string, function func() int64) metrics.FuncIntGauge

func (Registry) Gauge

func (r Registry) Gauge(name string) metrics.Gauge

func (*Registry) GaugeVec

func (r *Registry) GaugeVec(name string, labels []string) metrics.GaugeVec

GaugeVec creates a new gauges vector with given metric name and partitioned by the given label names.

func (Registry) Histogram

func (r Registry) Histogram(name string, buckets metrics.Buckets) metrics.Histogram

func (*Registry) HistogramVec

func (r *Registry) HistogramVec(name string, buckets metrics.Buckets, labels []string) metrics.HistogramVec

HistogramVec creates a new histograms vector with given metric name and buckets and partitioned by the given label names.

func (*Registry) IntGauge

func (r *Registry) IntGauge(name string) metrics.IntGauge

func (*Registry) IntGaugeVec

func (r *Registry) IntGaugeVec(name string, labels []string) metrics.IntGaugeVec

IntGaugeVec creates a new gauges vector with given metric name and partitioned by the given label names.

func (Registry) Timer

func (r Registry) Timer(name string) metrics.Timer

func (*Registry) TimerVec

func (r *Registry) TimerVec(name string, labels []string) metrics.TimerVec

TimerVec creates a new timers vector with given metric name and partitioned by the given label names.

func (Registry) WithPrefix

func (r Registry) WithPrefix(prefix string) metrics.Registry

WithPrefix creates new sub-scope, where each metric has prefix added to it name.

func (Registry) WithTags

func (r Registry) WithTags(tags map[string]string) metrics.Registry

WithTags creates new sub-scope, where each metric has tags attached to it.

type RegistryOpts

type RegistryOpts struct {
	Separator                  rune
	Prefix                     string
	Tags                       map[string]string
	AllowLoadRegisteredMetrics bool
}

func NewRegistryOpts

func NewRegistryOpts() *RegistryOpts

NewRegistryOpts returns new initialized instance of RegistryOpts

func (*RegistryOpts) AddTags

func (o *RegistryOpts) AddTags(tags map[string]string) *RegistryOpts

AddTags merges given tags with existing

func (*RegistryOpts) AppendPrefix

func (o *RegistryOpts) AppendPrefix(prefix string) *RegistryOpts

AppendPrefix adds given prefix as postfix to existing using separator

func (*RegistryOpts) SetPrefix

func (o *RegistryOpts) SetPrefix(prefix string) *RegistryOpts

SetPrefix overrides existing prefix

func (*RegistryOpts) SetSeparator

func (o *RegistryOpts) SetSeparator(separator rune) *RegistryOpts

SetSeparator overrides existing separator

func (*RegistryOpts) SetTags

func (o *RegistryOpts) SetTags(tags map[string]string) *RegistryOpts

SetTags overrides existing tags

type Timer

type Timer struct {
	Name  string
	Tags  map[string]string
	Value *atomic.Duration
}

Timer measures gauge duration.

func (*Timer) RecordDuration

func (t *Timer) RecordDuration(value time.Duration)

type TimerVec

type TimerVec struct {
	Vec MetricsVector
}

TimerVec stores timers and implements metrics.TimerVec interface

func (*TimerVec) Reset

func (v *TimerVec) Reset()

Reset deletes all metrics in this vector.

func (*TimerVec) With

func (v *TimerVec) With(tags map[string]string) metrics.Timer

With creates new or returns existing timer with given tags from vector. It will panic if tags keys set is not equal to vector labels.

type Vector

type Vector struct {
	Labels    []string
	Mtx       sync.RWMutex // Protects metrics.
	Metrics   map[uint64]interface{}
	NewMetric func(map[string]string) interface{}
}

Vector is base implementation of vector of metrics of any supported type

func (*Vector) Reset

func (v *Vector) Reset()

Reset deletes all metrics in this vector.

func (*Vector) With

func (v *Vector) With(tags map[string]string) interface{}

Jump to

Keyboard shortcuts

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