stats

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StatsCollectorRegistry = make(map[string]func() (ICollector, error))

StatsCollectorRegistry holds the a registry of stats collectors.

Functions

func RegisterCollector added in v0.0.5

func RegisterCollector(name string, createFunc func() (ICollector, error))

RegisterCollector registers a new stats collector with the given name.

Types

type HistogramStatsCollector

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

HistogramStatsCollector is a stats collector that collects histogram stats.

func NewHistogramStatsCollector

func NewHistogramStatsCollector() *HistogramStatsCollector

NewHistogramStatsCollector creates a new histogram stats collector.

func (*HistogramStatsCollector) Decr

func (c *HistogramStatsCollector) Decr(stat types.Stat, value int64)

Decr decrements the count of a statistic by the given value.

func (*HistogramStatsCollector) Gauge

func (c *HistogramStatsCollector) Gauge(stat types.Stat, value int64)

Gauge records the current value of a statistic.

func (*HistogramStatsCollector) GetStats added in v0.0.4

func (c *HistogramStatsCollector) GetStats() Stats

GetStats returns the stats collected by the stats collector. It calculates the mean, median, min, max, count, sum, and variance for each stat. It returns a map where the keys are the stat names and the values are the stat values.

func (*HistogramStatsCollector) Histogram

func (c *HistogramStatsCollector) Histogram(stat types.Stat, value int64)

Histogram records the statistical distribution of a set of values.

func (*HistogramStatsCollector) Incr

func (c *HistogramStatsCollector) Incr(stat types.Stat, value int64)

Incr increments the count of a statistic by the given value.

func (*HistogramStatsCollector) Mean

func (c *HistogramStatsCollector) Mean(stat types.Stat) float64

Mean returns the mean value of a statistic.

func (*HistogramStatsCollector) Median

func (c *HistogramStatsCollector) Median(stat types.Stat) float64

Median returns the median value of a statistic.

func (*HistogramStatsCollector) Percentile

func (c *HistogramStatsCollector) Percentile(stat types.Stat, p float64) float64

Percentile returns the pth percentile value of a statistic.

func (*HistogramStatsCollector) Timing

func (c *HistogramStatsCollector) Timing(stat types.Stat, value int64)

Timing records the time it took for an event to occur.

type ICollector added in v0.0.6

type ICollector interface {
	// Incr increments the count of a statistic by the given value.
	Incr(stat types.Stat, value int64)
	// Decr decrements the count of a statistic by the given value.
	Decr(stat types.Stat, value int64)
	// Timing records the time it took for an event to occur.
	Timing(stat types.Stat, value int64)
	// Gauge records the current value of a statistic.
	Gauge(stat types.Stat, value int64)
	// Histogram records the statistical distribution of a set of values.
	Histogram(stat types.Stat, value int64)
	// GetStats returns the collected statistics.
	GetStats() Stats
}

ICollector is an interface that defines the methods that a stats collector should implement.

func NewCollector added in v0.0.5

func NewCollector(statsCollectorName string) (ICollector, error)

NewCollector creates a new stats collector. The statsCollectorName parameter is used to select the stats collector from the registry.

type Stat

type Stat struct {
	// Mean value of the stat
	Mean float64
	// Median value of the stat
	Median float64
	// Min is the minumum value of the stat
	Min int64
	// Max maximum value of the stat
	Max int64
	// Values slice of all the values of the stat
	Values []int64
	// Count the number of values of the stat
	Count int
	// Sum of all the values of the stat
	Sum int64
	// Variance of the values of the stat
	Variance float64
}

Stat represents statistical data for a specific stat.

type Stats added in v0.0.4

type Stats map[string]*Stat

Stats is a map that stores statistical data. The keys are the stat names and the values are the stat values.

Jump to

Keyboard shortcuts

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