Documentation ¶
Index ¶
- Constants
- func AddSample(key string, val float64, tags ...Tag)
- func IncrCounter(key string, val float64, tags ...Tag)
- func MeasureSince(key string, start time.Time, tags ...Tag)
- func SetGauge(key string, val float64, tags ...Tag)
- func StringStartsWithOneOf(value string, items []string) bool
- func UpdateFilter(allow, block []string)
- type AggregateSample
- type BlackholeSink
- type Config
- type Describe
- type FanoutSink
- type GaugeValue
- type InmemSignal
- type InmemSink
- func (i *InmemSink) AddSample(key string, val float64, tags []Tag)
- func (i *InmemSink) Data() []*IntervalMetrics
- func (i *InmemSink) DisplayMetrics() (*Summary, error)
- func (i *InmemSink) IncrCounter(key string, val float64, tags []Tag)
- func (i *InmemSink) SetGauge(key string, val float64, tags []Tag)
- type IntervalMetrics
- type Metrics
- func (m *Metrics) AddSample(key string, val float64, tags ...Tag)
- func (m *Metrics) IncrCounter(key string, val float64, tags ...Tag)
- func (m *Metrics) MeasureSince(key string, start time.Time, tags ...Tag)
- func (m *Metrics) SetGauge(key string, val float64, tags ...Tag)
- func (m *Metrics) UpdateFilter(allow, block []string)
- type PointValue
- type Provider
- type SampledValue
- type Sink
- type Summary
- type Tag
Constants ¶
const ( TypeCounter = "counter" TypeSample = "sample" TypeGauge = "gauge" )
Define metrics type const
const ( // DefaultSignal is used with DefaultInmemSignal DefaultSignal = syscall.SIGUSR1 )
Variables ¶
This section is empty.
Functions ¶
func IncrCounter ¶
IncrCounter should accumulate values
func MeasureSince ¶
MeasureSince is for timing information
func StringStartsWithOneOf ¶ added in v0.2.0
StringStartsWithOneOf returns true if one of items slice is a prefix of specified value.
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(_ string, _ float64, _ []Tag)
AddSample is for timing information, where quantiles are used
func (*BlackholeSink) IncrCounter ¶
func (*BlackholeSink) IncrCounter(_ string, _ float64, _ []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", "sample") 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 the first metric prefixes to allow BlockedPrefixes []string // A list of the first metric prefixes to block FilterDefault bool // Whether to allow metrics by default }
Config is used to configure metrics settings
func DefaultConfig ¶
DefaultConfig provides a sane default configuration
func (*Config) AllowMetric ¶ added in v0.4.0
AllowMetric returns whether the metric should be allowed based on configured prefix filters Also return the applicable tags
type Describe ¶ added in v0.4.0
type Describe struct { // Type of the metric: counter|gauge|summary Type string // Name is the metric name Name string // Help provides description Help string // RequiredTags is a list of metric tags RequiredTags []string }
Describe provides metric description
func (*Describe) AddSample ¶ added in v0.4.0
AddSample is for timing information, where quantiles are used
func (*Describe) IncrCounter ¶ added in v0.4.0
IncrCounter should accumulate values
func (*Describe) MeasureSince ¶ added in v0.4.0
MeasureSince emits sample
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 float64, tags []Tag)
AddSample is for timing information, where quantiles are used
func (FanoutSink) IncrCounter ¶
func (fh FanoutSink) IncrCounter(key string, val float64, tags []Tag)
IncrCounter should accumulate values
type GaugeValue ¶
type GaugeValue struct { Name string Hash string `json:"-"` Value float64 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 // 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.
type PointValue ¶
PointValue provides point value
type Provider ¶
type Provider interface { SetGauge(key string, val float64, tags ...Tag) IncrCounter(key string, val float64, tags ...Tag) AddSample(key string, val float64, 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 float64, tags []Tag) // IncrCounter should accumulate values IncrCounter(key string, val float64, tags []Tag) // AddSample is for timing information, where quantiles are used AddSample(key string, val float64, tags []Tag) }
The Sink interface is used to transmit metrics information to an external system
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