stats

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2017 License: BSD-2-Clause Imports: 5 Imported by: 12

Documentation

Overview

Package stats provides an interface for instrumenting Empire.

Index

Constants

This section is empty.

Variables

View Source
var Null = &nullStats{}

Functions

func Gauge

func Gauge(ctx context.Context, name string, value float32, rate float32, tags []string) error

func Histogram

func Histogram(ctx context.Context, name string, value float32, rate float32, tags []string) error

func Inc

func Inc(ctx context.Context, name string, value int64, rate float32, tags []string) error

func Runtime

func Runtime(stats Stats)

Runtime enters into a loop, sampling and outputing the runtime stats periodically.

func SampleEvery

func SampleEvery(stats Stats, t time.Duration)

SampleEvery enters a loop, sampling at the specified interval

func Timing

func Timing(ctx context.Context, name string, value time.Duration, rate float32, tags []string) error

func WithStats

func WithStats(ctx context.Context, stats Stats) context.Context

WithStats returns a new context.Context with the Stats implementation embedded.

func WithTags

func WithTags(ctx context.Context, tags []string) context.Context

WithTags will return a context.Context where all metrics recorded with the embedded Stats implementation will include the given stats.

Types

type Dogstatsd

type Dogstatsd struct {
	*statsd.Client
}

Dogstatsd provides an implementation of the Stats interface backed by dogstatsd.

func NewDogstatsd

func NewDogstatsd(addr string) (*Dogstatsd, error)

NewDogstatsd returns a new Dogstatsd instance that sends statsd metrics to addr.

func (*Dogstatsd) Gauge

func (s *Dogstatsd) Gauge(name string, value float32, rate float32, tags []string) error

func (*Dogstatsd) Histogram

func (s *Dogstatsd) Histogram(name string, value float32, rate float32, tags []string) error

func (*Dogstatsd) Inc

func (s *Dogstatsd) Inc(name string, value int64, rate float32, tags []string) error

func (*Dogstatsd) Timing

func (s *Dogstatsd) Timing(name string, value time.Duration, rate float32, tags []string) error

type Stats

type Stats interface {
	Inc(name string, value int64, rate float32, tags []string) error
	Timing(name string, value time.Duration, rate float32, tags []string) error
	Gauge(name string, value float32, rate float32, tags []string) error
	Histogram(name string, value float32, rate float32, tags []string) error
}

Stats provides an interface for generating instruments, like guages and counts.

func FromContext

func FromContext(ctx context.Context) (Stats, bool)

FromContext returns the Stats implementation that's embedded in the context.

type Statsd

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

Statsd is an implementation of the Stats interface backed by statsd.

func NewStatsd

func NewStatsd(addr, prefix string) (*Statsd, error)

NewStatsd returns a new Statsd implementation that sends stats to addr.

func (*Statsd) Gauge

func (s *Statsd) Gauge(name string, value float32, rate float32, tags []string) error

func (*Statsd) Histogram

func (s *Statsd) Histogram(name string, value float32, rate float32, tags []string) error

func (*Statsd) Inc

func (s *Statsd) Inc(name string, value int64, rate float32, tags []string) error

func (*Statsd) Timing

func (s *Statsd) Timing(name string, value time.Duration, rate float32, tags []string) error

Jump to

Keyboard shortcuts

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