go-metrics: github.com/armon/go-metrics Index | Files | Directories

package metrics

import "github.com/armon/go-metrics"

Index

Package Files

const_unix.go inmem.go inmem_signal.go metrics.go sink.go start.go statsd.go statsite.go

Constants

const (
    // DefaultSignal is used with DefaultInmemSignal
    DefaultSignal = syscall.SIGUSR1
)

func AddSample Uses

func AddSample(key []string, val float32)

func EmitKey Uses

func EmitKey(key []string, val float32)

func IncrCounter Uses

func IncrCounter(key []string, val float32)

func MeasureSince Uses

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

func SetGauge Uses

func SetGauge(key []string, val float32)

Proxy all the methods to the globalMetrics instance

type AggregateSample Uses

type AggregateSample struct {
    Count       int       // The count of emitted pairs
    Rate        float64   // The count of emitted pairs per time unit (usually 1 second)
    Sum         float64   // The sum of values
    SumSq       float64   // The sum of squared values
    Min         float64   // Minimum value
    Max         float64   // Maximum value
    LastUpdated time.Time // When value was last updated
}

AggregateSample is used to hold aggregate metrics about a sample

func (*AggregateSample) Ingest Uses

func (a *AggregateSample) Ingest(v float64, rateDenom float64)

Ingest is used to update a sample

func (*AggregateSample) Mean Uses

func (a *AggregateSample) Mean() float64

Computes a mean of the values

func (*AggregateSample) Stddev Uses

func (a *AggregateSample) Stddev() float64

Computes a Stddev of the values

func (*AggregateSample) String Uses

func (a *AggregateSample) String() string

type BlackholeSink Uses

type BlackholeSink struct{}

BlackholeSink is used to just blackhole messages

func (*BlackholeSink) AddSample Uses

func (*BlackholeSink) AddSample(key []string, val float32)

func (*BlackholeSink) EmitKey Uses

func (*BlackholeSink) EmitKey(key []string, val float32)

func (*BlackholeSink) IncrCounter Uses

func (*BlackholeSink) IncrCounter(key []string, val float32)

func (*BlackholeSink) SetGauge Uses

func (*BlackholeSink) SetGauge(key []string, val float32)

type Config Uses

type Config struct {
    ServiceName          string        // Prefixed with keys to seperate services
    HostName             string        // Hostname to use. If not provided and EnableHostname, it will be os.Hostname
    EnableHostname       bool          // Enable prefixing gauge values with hostname
    EnableRuntimeMetrics bool          // Enables profiling of runtime metrics (GC, Goroutines, Memory)
    EnableTypePrefix     bool          // Prefixes key with a type ("counter", "gauge", "timer")
    TimerGranularity     time.Duration // Granularity of timers.
    ProfileInterval      time.Duration // Interval to profile runtime metrics
}

Config is used to configure metrics settings

func DefaultConfig Uses

func DefaultConfig(serviceName string) *Config

DefaultConfig provides a sane default configuration

type FanoutSink Uses

type FanoutSink []MetricSink

FanoutSink is used to sink to fanout values to multiple sinks

func (FanoutSink) AddSample Uses

func (fh FanoutSink) AddSample(key []string, val float32)

func (FanoutSink) EmitKey Uses

func (fh FanoutSink) EmitKey(key []string, val float32)

func (FanoutSink) IncrCounter Uses

func (fh FanoutSink) IncrCounter(key []string, val float32)

func (FanoutSink) SetGauge Uses

func (fh FanoutSink) SetGauge(key []string, val float32)

type InmemSignal Uses

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

InmemSignal is used to listen for a given signal, and when received, to dump the current metrics from the InmemSink to an io.Writer

func DefaultInmemSignal Uses

func DefaultInmemSignal(inmem *InmemSink) *InmemSignal

DefaultInmemSignal returns a new InmemSignal that responds to SIGUSR1 and writes output to stderr. Windows uses SIGBREAK

func NewInmemSignal Uses

func NewInmemSignal(inmem *InmemSink, sig syscall.Signal, w io.Writer) *InmemSignal

NewInmemSignal creates a new InmemSignal which listens for a given signal, and dumps the current metrics out to a writer

func (*InmemSignal) Stop Uses

func (i *InmemSignal) Stop()

Stop is used to stop the InmemSignal from listening

type InmemSink Uses

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

InmemSink provides a MetricSink that does in-memory aggregation without sending metrics over a network. It can be embedded within an application to provide profiling information.

func NewInmemSink Uses

func NewInmemSink(interval, retain time.Duration) *InmemSink

NewInmemSink is used to construct a new in-memory sink. Uses an aggregation interval and maximum retention period.

func (*InmemSink) AddSample Uses

func (i *InmemSink) AddSample(key []string, val float32)

func (*InmemSink) Data Uses

func (i *InmemSink) Data() []*IntervalMetrics

Data is used to retrieve all the aggregated metrics Intervals may be in use, and a read lock should be acquired

func (*InmemSink) EmitKey Uses

func (i *InmemSink) EmitKey(key []string, val float32)

func (*InmemSink) IncrCounter Uses

func (i *InmemSink) IncrCounter(key []string, val float32)

func (*InmemSink) SetGauge Uses

func (i *InmemSink) SetGauge(key []string, val float32)

type IntervalMetrics Uses

type IntervalMetrics struct {
    sync.RWMutex

    // The start time of the interval
    Interval time.Time

    // Gauges maps the key to the last set value
    Gauges map[string]float32

    // Points maps the string to the list of emitted values
    // from EmitKey
    Points map[string][]float32

    // Counters maps the string key to a sum of the counter
    // values
    Counters map[string]*AggregateSample

    // Samples maps the key to an AggregateSample,
    // which has the rolled up view of a sample
    Samples map[string]*AggregateSample
}

IntervalMetrics stores the aggregated metrics for a specific interval

func NewIntervalMetrics Uses

func NewIntervalMetrics(intv time.Time) *IntervalMetrics

NewIntervalMetrics creates a new IntervalMetrics for a given interval

type MetricSink Uses

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

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

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

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

The MetricSink interface is used to transmit metrics information to an external system

type Metrics Uses

type Metrics struct {
    Config
    // contains filtered or unexported fields
}

Metrics represents an instance of a metrics sink that can be used to emit

func New Uses

func New(conf *Config, sink MetricSink) (*Metrics, error)

New is used to create a new instance of Metrics

func NewGlobal Uses

func NewGlobal(conf *Config, sink MetricSink) (*Metrics, error)

NewGlobal is the same as New, but it assigns the metrics object to be used globally as well as returning it.

func (*Metrics) AddSample Uses

func (m *Metrics) AddSample(key []string, val float32)

func (*Metrics) EmitKey Uses

func (m *Metrics) EmitKey(key []string, val float32)

func (*Metrics) IncrCounter Uses

func (m *Metrics) IncrCounter(key []string, val float32)

func (*Metrics) MeasureSince Uses

func (m *Metrics) MeasureSince(key []string, start time.Time)

func (*Metrics) SetGauge Uses

func (m *Metrics) SetGauge(key []string, val float32)

type StatsdSink Uses

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

StatsdSink provides a MetricSink that can be used with a statsite or statsd metrics server. It uses only UDP packets, while StatsiteSink uses TCP.

func NewStatsdSink Uses

func NewStatsdSink(addr string) (*StatsdSink, error)

NewStatsdSink is used to create a new StatsdSink

func (*StatsdSink) AddSample Uses

func (s *StatsdSink) AddSample(key []string, val float32)

func (*StatsdSink) EmitKey Uses

func (s *StatsdSink) EmitKey(key []string, val float32)

func (*StatsdSink) IncrCounter Uses

func (s *StatsdSink) IncrCounter(key []string, val float32)

func (*StatsdSink) SetGauge Uses

func (s *StatsdSink) SetGauge(key []string, val float32)

func (*StatsdSink) Shutdown Uses

func (s *StatsdSink) Shutdown()

Close is used to stop flushing to statsd

type StatsiteSink Uses

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

StatsiteSink provides a MetricSink that can be used with a statsite metrics server

func NewStatsiteSink Uses

func NewStatsiteSink(addr string) (*StatsiteSink, error)

NewStatsiteSink is used to create a new StatsiteSink

func (*StatsiteSink) AddSample Uses

func (s *StatsiteSink) AddSample(key []string, val float32)

func (*StatsiteSink) EmitKey Uses

func (s *StatsiteSink) EmitKey(key []string, val float32)

func (*StatsiteSink) IncrCounter Uses

func (s *StatsiteSink) IncrCounter(key []string, val float32)

func (*StatsiteSink) SetGauge Uses

func (s *StatsiteSink) SetGauge(key []string, val float32)

func (*StatsiteSink) Shutdown Uses

func (s *StatsiteSink) Shutdown()

Close is used to stop flushing to statsite

Directories

PathSynopsis
circonus
datadog
prometheus

Package metrics imports 14 packages (graph) and is imported by 151 packages. Updated 2017-02-23. Refresh now. Tools for package owners.