stats

package
v1.5.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CountType     = "count"
	TimerType     = "timer"
	GaugeType     = "gauge"
	HistogramType = "histogram"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter added in v1.2.0

type Counter interface {
	Count(n int)
	Increment()
}

Counter represents a counter metric

type Gauge added in v1.2.0

type Gauge interface {
	Gauge(value interface{})
}

Gauge represents a gauge metric

type Histogram added in v1.2.0

type Histogram interface {
	Observe(value float64)
}

Histogram represents a histogram metric

type Measurement added in v1.2.0

type Measurement interface {
	Counter
	Gauge
	Histogram
	Timer
}

Measurement provides all stat measurement functions TODO: the API should not return a union of measurement methods, but rather a distinct type for each measurement type

type Stats added in v0.1.10

type Stats interface {
	// NewStat creates an untagged measurement
	NewStat(name, statType string) (m Measurement)

	// NewTaggedStat creates a tagged measurement with a sampling rate of 1.0
	NewTaggedStat(name, statType string, tags Tags) Measurement

	// NewSampledTaggedStat creates a tagged measurement with the configured sampling rate (statsSamplingRate)
	NewSampledTaggedStat(name, statType string, tags Tags) Measurement

	// Start starts the stats service. It tries to connect to statsd server once and returns immediately.
	// If it fails to connect, it will retry in the background indefinitely, however any stats published in the meantime will be lost.
	Start(ctx context.Context)

	// Stop stops the service and collection of periodic stats.
	Stop()
}

Stats manages stat Measurements

var Default Stats

Default is the default (singleton) Stats instance

func NewStats added in v1.2.0

func NewStats(config *config.Config, loggerFactory *logger.Factory, metricManager metric.Manager) Stats

NewStats create a new Stats instance using the provided config, logger factory and metric manager as dependencies

type Tags added in v0.1.10

type Tags map[string]string

Tags is a map of key value pairs

func (Tags) String added in v0.2.0

func (t Tags) String() string

String returns all key value pairs as a single string, separated by commas, sorted by increasing key order

func (Tags) Strings added in v0.2.0

func (t Tags) Strings() []string

Strings returns all key value pairs as an ordered list of strings, sorted by increasing key order

type Timer added in v1.2.0

type Timer interface {
	SendTiming(duration time.Duration)
	Since(start time.Time)
	RecordDuration() func()
}

Timer represents a timer metric

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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