Documentation ¶
Index ¶
- Constants
- Variables
- func AddSample(key []string, val float32, tags ...Tag)
- func IncrCounter(key []string, val float32, tags ...Tag)
- func MeasureSince(key []string, start time.Time, tags ...Tag)
- func SetGauge(key []string, val float32, tags ...Tag)
- func UpdateFilter(allow, block []string)
- func UpdateFilterAndLabels(allow, block, allowedLabels, blockedLabels []string)
- type AggregateSample
- type BlackholeSink
- type Config
- type DogStatsdSink
- func (s *DogStatsdSink) AddSample(key []string, val float32, tags []Tag)
- func (s *DogStatsdSink) EnableHostNamePropagation()
- func (s *DogStatsdSink) IncrCounter(key []string, val float32, tags []Tag)
- func (s *DogStatsdSink) SetGauge(key []string, val float32, tags []Tag)
- func (s *DogStatsdSink) SetTags(tags []string)
- type FanoutSink
- type GaugeValue
- type InmemSignal
- type InmemSink
- func (i *InmemSink) AddSample(key []string, val float32, tags []Tag)
- func (i *InmemSink) Data() []*IntervalMetrics
- func (i *InmemSink) DisplayMetrics() (*Summary, error)
- func (i *InmemSink) IncrCounter(key []string, val float32, tags []Tag)
- func (i *InmemSink) SetGauge(key []string, val float32, tags []Tag)
- type IntervalMetrics
- type Metrics
- func (m *Metrics) AddSample(key []string, val float32, tags ...Tag)
- func (m *Metrics) IncrCounter(key []string, val float32, tags ...Tag)
- func (m *Metrics) MeasureSince(key []string, start time.Time, tags ...Tag)
- func (m *Metrics) SetGauge(key []string, val float32, tags ...Tag)
- func (m *Metrics) UpdateFilter(allow, block []string)
- func (m *Metrics) UpdateFilterAndLabels(allow, block, allowedLabels, blockedLabels []string)
- type PointValue
- type PrometheusOpts
- type PrometheusSink
- func (p *PrometheusSink) AddSample(parts []string, val float32, tags []Tag)
- func (p *PrometheusSink) Collect(c chan<- prometheus.Metric)
- func (p *PrometheusSink) Describe(c chan<- *prometheus.Desc)
- func (p *PrometheusSink) EmitKey(key []string, val float32)
- func (p *PrometheusSink) IncrCounter(parts []string, val float32, tags []Tag)
- func (p *PrometheusSink) SetGauge(parts []string, val float32, tags []Tag)
- type Provider
- type SampledValue
- type Sink
- type StatsdSink
- type Summary
- type Tag
Constants ¶
const ( // DefaultSignal is used with DefaultInmemSignal DefaultSignal = syscall.SIGUSR1 )
Variables ¶
var ( // DefaultPrometheusOpts is the default set of options used when creating a // PrometheusSink. DefaultPrometheusOpts = PrometheusOpts{ Expiration: 60 * time.Second, } )
Functions ¶
func IncrCounter ¶
IncrCounter should accumulate values
func MeasureSince ¶
MeasureSince is for timing information
func UpdateFilterAndLabels ¶
func UpdateFilterAndLabels(allow, block, allowedLabels, blockedLabels []string)
UpdateFilterAndLabels set allow/block prefixes of metrics while allowedLabels and blockedLabels - when not nil - allow filtering of labels in order to block/allow globally labels (especially useful when having large number of values for a given label). See README.md for more information about usage.
Types ¶
type AggregateSample ¶
type AggregateSample struct { Count int // The count of emitted pairs Rate float64 // The values rate 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 ¶
func (a *AggregateSample) Ingest(v float64, rateDenom float64)
Ingest is used to update a sample
func (*AggregateSample) Mean ¶
func (a *AggregateSample) Mean() float64
Mean computes a mean of the values
func (*AggregateSample) Stddev ¶
func (a *AggregateSample) Stddev() float64
Stddev computes a Stddev of the values
func (*AggregateSample) String ¶
func (a *AggregateSample) String() string
type BlackholeSink ¶
type BlackholeSink struct{}
BlackholeSink is used to just blackhole messages
func (*BlackholeSink) AddSample ¶
func (*BlackholeSink) AddSample(key []string, val float32, tags []Tag)
AddSample is for timing information, where quantiles are used
func (*BlackholeSink) IncrCounter ¶
func (*BlackholeSink) IncrCounter(key []string, val float32, tags []Tag)
IncrCounter should accumulate values
type Config ¶
type Config struct { ServiceName string // Prefixed with keys to separate 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 GlobalTags []Tag // Tags to add to every metric GlobalPrefix string // Prefix to add to every metric 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 AllowedLabels []string // A list of metric labels to allow, with '.' as the separator BlockedLabels []string // A list of metric labels to block, with '.' as the separator FilterDefault bool // Whether to allow metrics by default }
Config is used to configure metrics settings
func DefaultConfig ¶
DefaultConfig provides a sane default configuration
type DogStatsdSink ¶
type DogStatsdSink struct {
// contains filtered or unexported fields
}
DogStatsdSink provides a MetricSink that can be used with a dogstatsd server. It utilizes the Dogstatsd client at github.com/DataDog/datadog-go/statsd
func NewDogStatsdSink ¶
func NewDogStatsdSink(addr string, hostName string) (*DogStatsdSink, error)
NewDogStatsdSink is used to create a new DogStatsdSink with sane defaults
func (*DogStatsdSink) AddSample ¶
func (s *DogStatsdSink) AddSample(key []string, val float32, tags []Tag)
AddSample is for timing information, where quantiles are used
func (*DogStatsdSink) EnableHostNamePropagation ¶
func (s *DogStatsdSink) EnableHostNamePropagation()
EnableHostNamePropagation forces a Dogstatsd `host` tag with the value specified by `s.HostName` Since the go-metrics package has its own mechanism for attaching a hostname to metrics, setting the `propagateHostname` flag ensures that `s.HostName` overrides the host tag naively set by the DogStatsd server
func (*DogStatsdSink) IncrCounter ¶
func (s *DogStatsdSink) IncrCounter(key []string, val float32, tags []Tag)
IncrCounter should accumulate values
func (*DogStatsdSink) SetGauge ¶
func (s *DogStatsdSink) SetGauge(key []string, val float32, tags []Tag)
SetGauge should retain the last value it is set to
func (*DogStatsdSink) SetTags ¶
func (s *DogStatsdSink) SetTags(tags []string)
SetTags sets common tags on the Dogstatsd Client that will be sent along with all dogstatsd packets. Ref: http://docs.datadoghq.com/guides/dogstatsd/#tags
type FanoutSink ¶
type FanoutSink []Sink
FanoutSink is used to sink to fanout values to multiple sinks
func NewFanoutSink ¶
func NewFanoutSink(sinks ...Sink) FanoutSink
NewFanoutSink creates fan-out sink
func (FanoutSink) AddSample ¶
func (fh FanoutSink) AddSample(key []string, val float32, tags []Tag)
AddSample is for timing information, where quantiles are used
func (FanoutSink) IncrCounter ¶
func (fh FanoutSink) IncrCounter(key []string, val float32, tags []Tag)
IncrCounter should accumulate values
type GaugeValue ¶
type GaugeValue struct { Name string Hash string `json:"-"` Value float32 Labels []Tag `json:"-"` DisplayLabels map[string]string `json:"Labels"` }
GaugeValue provides gauge value
type InmemSignal ¶
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 ¶
func DefaultInmemSignal(inmem *InmemSink) *InmemSignal
DefaultInmemSignal returns a new InmemSignal that responds to SIGUSR1 and writes output to stderr. Windows uses SIGBREAK
func NewInmemSignal ¶
NewInmemSignal creates a new InmemSignal which listens for a given signal, and dumps the current metrics out to a writer
func (*InmemSignal) Stop ¶
func (i *InmemSignal) Stop()
Stop is used to stop the InmemSignal from listening
type InmemSink ¶
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 ¶
NewInmemSink is used to construct a new in-memory sink. Uses an aggregation interval and maximum retention period.
func (*InmemSink) Data ¶
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 ¶
DisplayMetrics returns a summary of the metrics from the most recent finished interval.
func (*InmemSink) IncrCounter ¶
IncrCounter should accumulate values
type IntervalMetrics ¶
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 ¶
func NewIntervalMetrics(intv time.Time) *IntervalMetrics
NewIntervalMetrics creates a new IntervalMetrics for a given interval
type Metrics ¶
type Metrics struct { Config // contains filtered or unexported fields }
Metrics represents an instance of a metrics sink that can be used to emit
func NewGlobal ¶
NewGlobal is the same as New, but it assigns the metrics object to be used globally as well as returning it.
func (*Metrics) IncrCounter ¶
IncrCounter should accumulate values
func (*Metrics) MeasureSince ¶
MeasureSince is for timing information
func (*Metrics) UpdateFilter ¶
UpdateFilter overwrites the existing filter with the given rules.
func (*Metrics) UpdateFilterAndLabels ¶
UpdateFilterAndLabels overwrites the existing filter with the given rules.
type PointValue ¶
PointValue provides point value
type PrometheusOpts ¶
type PrometheusOpts struct { // Expiration is the duration a metric is valid for, after which it will be // untracked. If the value is zero, a metric is never expired. Expiration time.Duration }
PrometheusOpts is used to configure the Prometheus Sink
type PrometheusSink ¶
type PrometheusSink struct {
// contains filtered or unexported fields
}
PrometheusSink provides a MetricSink that can be used with a prometheus server.
func NewPrometheusSink ¶
func NewPrometheusSink() (*PrometheusSink, error)
NewPrometheusSink creates a new PrometheusSink using the default options.
func NewPrometheusSinkFrom ¶
func NewPrometheusSinkFrom(opts PrometheusOpts) (*PrometheusSink, error)
NewPrometheusSinkFrom creates a new PrometheusSink using the passed options.
func (*PrometheusSink) AddSample ¶
func (p *PrometheusSink) AddSample(parts []string, val float32, tags []Tag)
AddSample is for timing information, where quantiles are used
func (*PrometheusSink) Collect ¶
func (p *PrometheusSink) Collect(c chan<- prometheus.Metric)
Collect meets the collection interface and allows us to enforce our expiration logic to clean up ephemeral metrics if their value haven't been set for a duration exceeding our allowed expiration time.
func (*PrometheusSink) Describe ¶
func (p *PrometheusSink) Describe(c chan<- *prometheus.Desc)
Describe is needed to meet the Collector interface.
func (*PrometheusSink) EmitKey ¶
func (p *PrometheusSink) EmitKey(key []string, val float32)
EmitKey is not implemented. Prometheus doesn’t offer a type for which an arbitrary number of values is retained, as Prometheus works with a pull model, rather than a push model.
func (*PrometheusSink) IncrCounter ¶
func (p *PrometheusSink) IncrCounter(parts []string, val float32, tags []Tag)
IncrCounter should accumulate values
type Provider ¶
type Provider interface { SetGauge(key []string, val float32, tags ...Tag) IncrCounter(key []string, val float32, tags ...Tag) AddSample(key []string, val float32, tags ...Tag) MeasureSince(key []string, start time.Time, tags ...Tag) }
Provider basics
type SampledValue ¶
type SampledValue struct { Name string Hash string `json:"-"` *AggregateSample Mean float64 Stddev float64 Labels []Tag `json:"-"` DisplayLabels map[string]string `json:"Labels"` }
SampledValue provides sample value
type Sink ¶
type Sink interface { // SetGauge should retain the last value it is set to SetGauge(key []string, val float32, tags []Tag) // IncrCounter should accumulate values IncrCounter(key []string, val float32, tags []Tag) // AddSample is for timing information, where quantiles are used AddSample(key []string, val float32, tags []Tag) }
The Sink interface is used to transmit metrics information to an external system
func NewInmemSinkFromURL ¶
NewInmemSinkFromURL creates an InmemSink from a URL. It is used (and tested) from NewMetricSinkFromURL.
func NewMetricSinkFromURL ¶
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 "retain" query parameters must be specified with valid durations, see NewInmemSink for details.
type StatsdSink ¶
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 ¶
func NewStatsdSink(addr string) (*StatsdSink, error)
NewStatsdSink is used to create a new StatsdSink
func (*StatsdSink) AddSample ¶
func (s *StatsdSink) AddSample(key []string, val float32, tags []Tag)
AddSample is for timing information, where quantiles are used
func (*StatsdSink) IncrCounter ¶
func (s *StatsdSink) IncrCounter(key []string, val float32, tags []Tag)
IncrCounter should accumulate values
func (*StatsdSink) SetGauge ¶
func (s *StatsdSink) SetGauge(key []string, val float32, tags []Tag)
SetGauge should retain the last value it is set to
func (*StatsdSink) Shutdown ¶
func (s *StatsdSink) Shutdown()
Shutdown is used to stop flushing to statsd
type Summary ¶
type Summary struct { Timestamp string Gauges []GaugeValue Points []PointValue Counters []SampledValue Samples []SampledValue }
Summary holds a roll-up of metrics info for a given interval