telemetry

package
v0.0.0-...-8f69376 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountCall

func CountCall(metrics Metrics, key string, keyn ...string) func(*error)

Types

type Blackhole

type Blackhole struct{}

Blackhole implements the Metrics interface, but throws away the metric data Useful for satisfying the Metrics interface when testing code which depends on it.

func (Blackhole) AddSample

func (Blackhole) AddSample(key []string, val float32)

func (Blackhole) AddSampleWithLabels

func (Blackhole) AddSampleWithLabels(key []string, val float32, labels []Label)

func (Blackhole) EmitKey

func (Blackhole) EmitKey(key []string, val float32)

func (Blackhole) IncrCounter

func (Blackhole) IncrCounter(key []string, val float32)

func (Blackhole) IncrCounterWithLabels

func (Blackhole) IncrCounterWithLabels(key []string, val float32, labels []Label)

func (Blackhole) MeasureSince

func (Blackhole) MeasureSince(key []string, start time.Time)

func (Blackhole) MeasureSinceWithLabels

func (Blackhole) MeasureSinceWithLabels(key []string, start time.Time, labels []Label)

func (Blackhole) SetGauge

func (Blackhole) SetGauge(key []string, val float32)

func (Blackhole) SetGaugeWithLabels

func (Blackhole) SetGaugeWithLabels(key []string, val float32, labels []Label)

type CallCounter

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

CallCounter is used to track timing and other information about a "call". It is intended to be scoped to a function with a defer and a named error value, if applicable, like so:

func Foo() (err error) {
    call := StartCall(metrics, "foo")
    defer call.Done(&err)

    call.AddLabel("food", "burgers")
}

In the simplest case, if no labels are going to be added, the CountCall function provides an easier interface:

func Foo() (err error) {
    defer CountCall(metrics, "foo")(&err)
}

func StartCall

func StartCall(metrics Metrics, key string, keyn ...string) *CallCounter

StartCall starts a "call", which when finished via Done() will emit timing and error related metrics.

func (*CallCounter) AddLabel

func (c *CallCounter) AddLabel(name, value string)

AddLabel adds a label to be emitted with the call counter. It is safe to call from multiple goroutines.

func (*CallCounter) Done

func (c *CallCounter) Done(errp *error)

Done finishes the "call" and emits metrics. No other calls to the CallCounter should be done during or after the call to Done. In other words, it is not thread-safe and is intended to be the final call to the CallCounter struct.

type Label

type Label = metrics.Label

type Metrics

type Metrics interface {
	// A Gauge should retain the last value it is set to
	SetGauge(key []string, val float32)
	SetGaugeWithLabels(key []string, val float32, labels []Label)

	// Should emit a Key/Value pair for each call
	EmitKey(key []string, val float32)

	// Counters should accumulate values
	IncrCounter(key []string, val float32)
	IncrCounterWithLabels(key []string, val float32, labels []Label)

	// Samples are for timing information, where quantiles are used
	AddSample(key []string, val float32)
	AddSampleWithLabels(key []string, val float32, labels []Label)

	// A convenience function for measuring elapsed time with a single line
	MeasureSince(key []string, start time.Time)
	MeasureSinceWithLabels(key []string, start time.Time, labels []Label)
}

func WithLabels

func WithLabels(metrics Metrics, labels []Label) Metrics

type MetricsConfig

type MetricsConfig struct {
	Logger      io.Writer
	ServiceName string
	Sinks       []Sink
}

type MetricsImpl

type MetricsImpl struct {
	*metrics.Metrics
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(c *MetricsConfig) *MetricsImpl

NewMetrics returns a Metric implementation

func (*MetricsImpl) Stop

func (t *MetricsImpl) Stop()

type Sink

type Sink = metrics.MetricSink

Jump to

Keyboard shortcuts

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