telemetry

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(mp MetricPrefix, name string) expvar.Var

Get retrieves a named exported variable with the given MetricPrefix. It returns nil if the name has not been registered.

Types

type Counter

type Counter struct {
	expvar.Int
	Labels map[string]string
}

A Counter is a monotonically-increasing integer expvar associated with a set of labels expressed as a key-value string map.

Note that exporting custom labels for Counters to Stackdriver is only implemented for counters that are part of a CounterMap.

func NewCounter

func NewCounter(mp MetricPrefix, name string) *Counter

NewCounter creates and exports a new Counter for the MetricPrefix.

func (*Counter) Increment

func (c *Counter) Increment()

Increment adds one to the counter's expvar value.

func (*Counter) IntValue

func (c *Counter) IntValue() int

IntValue returns the counter's value as an int rather than an int64. Tests are generally written with int types, so this is useful to avoid scattering type casts around the test codebase.

type CounterMap

type CounterMap struct {
	expvar.Map

	LabelKeys []string
	// contains filtered or unexported fields
}

A CounterMap is used to export a set of related Counters which have the same label keys.

func NewCounterMap

func NewCounterMap(mp MetricPrefix, name string, labelKeys ...string) *CounterMap

NewCounterMap creates and exports a new CounterMap for the MetricPrefix.

func (*CounterMap) Counter

func (cm *CounterMap) Counter(labelValues ...string) (*Counter, error)

Counter retrieves or creates a Counter with a given set of label values.

func (*CounterMap) MustCounter

func (cm *CounterMap) MustCounter(labelValues ...string) *Counter

MustCounter is a version of Counter that panics on error, for use in init functions.

type MetricPrefix

type MetricPrefix string

A MetricPrefix is a path element prepended to metric names.

const Nozzle MetricPrefix = "stackdriver-nozzle"

Nozzle is the prefix under which the nozzle exports metrics about its own operation. It's created here because metrics will be created in many places throughout the Nozzle's code base.

func (MetricPrefix) Qualify

func (mp MetricPrefix) Qualify(name string) string

Qualify returns the metric name prepended by the metric prefix and "/".

type Reporter

type Reporter interface {
	Start(ctx context.Context)
}

Reporter aggregates telemetry registered with expvar and reports it to Sink endpoints

func NewReporter

func NewReporter(period time.Duration, sinks ...Sink) Reporter

NewReporter provides a time based Reporter

type Sink

type Sink interface {
	// Init is called a single time when the Reporter is starting before any data is reported
	Init([]*expvar.KeyValue)
	// Report is a snapshot of the cumulative telemetry values at the current time
	Report([]*expvar.KeyValue)
}

Sink represents an endpoint that records telemetry to an external source

func NewLogSink

func NewLogSink(logger lager.Logger) Sink

NewLogSink provides a Sink that writes Reports to a lager.Logger

Jump to

Keyboard shortcuts

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