metrics

package
v0.0.0-...-3611cfd Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTags

func FormatTags(tags Tags) string

FormatTags is used by receivers and sinks to convert a map of tags into a string that can be used as a map key

func ParseTags

func ParseTags(tagString string) (map[string]string, error)

ParseTags converts a string formatted using formatTags(see above) into a map of tags

Types

type MockSink

type MockSink struct {
	Invocations map[string]int
	// contains filtered or unexported fields
}

MockSink is the mock implementation of sink to be used in tests for mocking purposes

func NewMockSink

func NewMockSink() *MockSink

NewMockSink returns the mock sink that adheres to the Sink interface and has utility methods to assert on

func (*MockSink) Close

func (sink *MockSink) Close()

Close simulates close of the flush loop

func (*MockSink) Flush

func (sink *MockSink) Flush() error

Flush simulates the flush of the buffered metrics

func (*MockSink) Handle

func (sink *MockSink) Handle(metric string, tags Tags, value float64, metricType metricType) error

Handle simluates piping out the metrics with tags and a value increses counters that can be asserted

func (*MockSink) NumFlushes

func (sink *MockSink) NumFlushes() int

NumFlushes returns number of times flush was called

func (*MockSink) NumInvocations

func (sink *MockSink) NumInvocations() int

NumInvocations returns the number of invocations to the handle

type PerMetricCumulativeHistogramBounds

type PerMetricCumulativeHistogramBounds []struct {
	Suffix string
	Bounds []int64
}

PerMetricCumulativeHistogramBounds is used to specify for which metrics cumulative histogram counters should be reported, and what bucket boundaries to use. For example, if it contains an entry {"foo", {1, 10, 100}}, for any metricTypeStat metric named *foo, four additional counters will be created, with suffixes ".less_than.{1,10,100,inf}" appended to the original metric name, representing the number of observations with observed values less than 1, 10, 100, and infinity, respectively. If multiple entries match a given metric, the first match will be used.

type Receiver

type Receiver interface {
	Incr(name string)
	IncrBy(name string, amount float64)
	AddStat(name string, value float64)
	SetGauge(name string, value float64)

	ScopePrefix(prefix string) Receiver
	ScopeTags(tags Tags) Receiver
	Scope(prefix string, tags Tags) Receiver

	StartStopwatch(name string) Stopwatch
}

Receiver is the interface to metrics that handles things like counters and gauges. An implementation of this receiver can be passed to flight recorder to track metrics

var Null Receiver = &receiver{
	scopes: make(map[string]*receiver),
	sink:   NullSink,
}

Null is the no op receiver

func NewReceiver

func NewReceiver(sink Sink) Receiver

NewReceiver returns an implementation of the receiver with the specified sink

type Sink

type Sink interface {
	Handle(metric string, tags Tags, value float64, metricType metricType) error
	Flush() error
	Close()
}

Sink is the interface to where the metrics get reported. Sink is the actual output pipe of the metrics reporting. An example of sink is statsd sink

var NullSink Sink = &nullSink{}

NullSink is the no op sink

func NewLocalSink

func NewLocalSink(dst Sink, flushThreshold int, perMetricCumulativeHistogramBounds PerMetricCumulativeHistogramBounds) Sink

NewLocalSink returns an implementation of sink. Pass in the destination sink like statsd, and perMetricCumulativeHistogramBounds to add histogram metrics

func NewStatsdSink

func NewStatsdSink(addr string) (Sink, error)

NewStatsdSink returns a Sink for statsd pass the address of the statsd daemon to it

func NewWavefrontSink

func NewWavefrontSink(origin string, tags map[string]string, hostPorts []string) Sink

NewWavefrontSink returns a sink for wavefront.

type Stopwatch

type Stopwatch interface {
	Stop()
}

Stopwatch is used for measuring time spent in an operation

type Tags

type Tags map[string]string

Tags are additional metadata with the metric name, keep in mind that these can't be high cardinality

Jump to

Keyboard shortcuts

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