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_endpoint.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 AddSampleWithLabels Uses

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

func EmitKey Uses

func EmitKey(key []string, val float32)

func IncrCounter Uses

func IncrCounter(key []string, val float32)

func IncrCounterWithLabels Uses

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

func MeasureSince Uses

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

func MeasureSinceWithLabels Uses

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

func SetGauge Uses

func SetGauge(key []string, val float32)

Proxy all the methods to the globalMetrics instance

func SetGaugeWithLabels Uses

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

func UpdateFilter Uses

func UpdateFilter(allow, block []string)

type AggregateSample Uses

type AggregateSample struct {
    Count       int       // The count of emitted pairs
    Rate        float64   `json:"-"` // The count of emitted pairs per time unit (usually 1 second)
    Sum         float64   // The sum of values
    SumSq       float64   `json:"-"` // The sum of squared values
    Min         float64   // Minimum value
    Max         float64   // Maximum value
    LastUpdated time.Time `json:"-"` // 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) AddSampleWithLabels Uses

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

func (*BlackholeSink) EmitKey Uses

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

func (*BlackholeSink) IncrCounter Uses

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

func (*BlackholeSink) IncrCounterWithLabels Uses

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

func (*BlackholeSink) SetGauge Uses

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

func (*BlackholeSink) SetGaugeWithLabels Uses

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

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
    EnableHostnameLabel  bool          // Enable adding hostname to labels
    EnableServiceLabel   bool          // Enable adding service to labels
    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

    AllowedPrefixes []string // A list of metric prefixes to allow, with '.' as the separator
    BlockedPrefixes []string // A list of metric prefixes to block, with '.' as the separator
    FilterDefault   bool     // Whether to allow metrics by default
}

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) AddSampleWithLabels Uses

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

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) IncrCounterWithLabels Uses

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

func (FanoutSink) SetGauge Uses

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

func (FanoutSink) SetGaugeWithLabels Uses

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

type GaugeValue Uses

type GaugeValue struct {
    Name  string
    Hash  string `json:"-"`
    Value float32

    Labels        []Label           `json:"-"`
    DisplayLabels map[string]string `json:"Labels"`
}

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) AddSampleWithLabels Uses

func (i *InmemSink) AddSampleWithLabels(key []string, val float32, labels []Label)

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) DisplayMetrics Uses

func (i *InmemSink) DisplayMetrics(resp http.ResponseWriter, req *http.Request) (interface{}, error)

DisplayMetrics returns a summary of the metrics from the most recent finished interval.

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) IncrCounterWithLabels Uses

func (i *InmemSink) IncrCounterWithLabels(key []string, val float32, labels []Label)

func (*InmemSink) SetGauge Uses

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

func (*InmemSink) SetGaugeWithLabels Uses

func (i *InmemSink) SetGaugeWithLabels(key []string, val float32, labels []Label)

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]GaugeValue

    // 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]SampledValue

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

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 Label Uses

type Label struct {
    Name  string
    Value string
}

type MetricSink Uses

type MetricSink 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)
}

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

func NewInmemSinkFromURL Uses

func NewInmemSinkFromURL(u *url.URL) (MetricSink, error)

NewInmemSinkFromURL creates an InmemSink from a URL. It is used (and tested) from NewMetricSinkFromURL.

func NewMetricSinkFromURL Uses

func NewMetricSinkFromURL(urlStr string) (MetricSink, error)

NewMetricSinkFromURL allows a generic URL input to configure any of the supported sinks. The scheme of the URL identifies the type of the sink, the and query parameters are used to set options.

"statsd://" - Initializes a StatsdSink. The host and port are passed through as the "addr" of the sink

"statsite://" - Initializes a StatsiteSink. The host and port become the "addr" of the sink

"inmem://" - Initializes an InmemSink. The host and port are ignored. The "interval" and "duration" query parameters must be specified with valid durations, see NewInmemSink for details.

func NewStatsdSinkFromURL Uses

func NewStatsdSinkFromURL(u *url.URL) (MetricSink, error)

NewStatsdSinkFromURL creates an StatsdSink from a URL. It is used (and tested) from NewMetricSinkFromURL.

func NewStatsiteSinkFromURL Uses

func NewStatsiteSinkFromURL(u *url.URL) (MetricSink, error)

NewStatsiteSinkFromURL creates an StatsiteSink from a URL. It is used (and tested) from NewMetricSinkFromURL.

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) AddSampleWithLabels Uses

func (m *Metrics) AddSampleWithLabels(key []string, val float32, labels []Label)

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) IncrCounterWithLabels Uses

func (m *Metrics) IncrCounterWithLabels(key []string, val float32, labels []Label)

func (*Metrics) MeasureSince Uses

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

func (*Metrics) MeasureSinceWithLabels Uses

func (m *Metrics) MeasureSinceWithLabels(key []string, start time.Time, labels []Label)

func (*Metrics) SetGauge Uses

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

func (*Metrics) SetGaugeWithLabels Uses

func (m *Metrics) SetGaugeWithLabels(key []string, val float32, labels []Label)

func (*Metrics) UpdateFilter Uses

func (m *Metrics) UpdateFilter(allow, block []string)

UpdateFilter overwrites the existing filter with the given rules.

type MetricsSummary Uses

type MetricsSummary struct {
    Timestamp string
    Gauges    []GaugeValue
    Points    []PointValue
    Counters  []SampledValue
    Samples   []SampledValue
}

MetricsSummary holds a roll-up of metrics info for a given interval

type PointValue Uses

type PointValue struct {
    Name   string
    Points []float32
}

type SampledValue Uses

type SampledValue struct {
    Name string
    Hash string `json:"-"`
    *AggregateSample
    Mean   float64
    Stddev float64

    Labels        []Label           `json:"-"`
    DisplayLabels map[string]string `json:"Labels"`
}

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) AddSampleWithLabels Uses

func (s *StatsdSink) AddSampleWithLabels(key []string, val float32, labels []Label)

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) IncrCounterWithLabels Uses

func (s *StatsdSink) IncrCounterWithLabels(key []string, val float32, labels []Label)

func (*StatsdSink) SetGauge Uses

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

func (*StatsdSink) SetGaugeWithLabels Uses

func (s *StatsdSink) SetGaugeWithLabels(key []string, val float32, labels []Label)

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) AddSampleWithLabels Uses

func (s *StatsiteSink) AddSampleWithLabels(key []string, val float32, labels []Label)

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) IncrCounterWithLabels Uses

func (s *StatsiteSink) IncrCounterWithLabels(key []string, val float32, labels []Label)

func (*StatsiteSink) SetGauge Uses

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

func (*StatsiteSink) SetGaugeWithLabels Uses

func (s *StatsiteSink) SetGaugeWithLabels(key []string, val float32, labels []Label)

func (*StatsiteSink) Shutdown Uses

func (s *StatsiteSink) Shutdown()

Close is used to stop flushing to statsite

Directories

PathSynopsis
circonus
datadog
prometheus

Package metrics imports 19 packages (graph) and is imported by 231 packages. Updated 2017-09-14. Refresh now. Tools for package owners.