Documentation ¶
Overview ¶
Package metrics contains a type for aggregating and propagating metrics to various services based on configuration.
Index ¶
- Variables
- func Descriptions() string
- func SanitiseConfig(conf Config) (interface{}, error)
- type Config
- type DudType
- type HTTP
- type Prometheus
- func (p *Prometheus) Close() error
- func (p *Prometheus) Decr(stat string, value int64) error
- func (p *Prometheus) Gauge(stat string, value int64) error
- func (p *Prometheus) HandlerFunc() http.HandlerFunc
- func (p *Prometheus) Incr(stat string, value int64) error
- func (p *Prometheus) Timing(stat string, delta int64) error
- type PrometheusConfig
- type Riemann
- type RiemannConfig
- type Statsd
- type StatsdConfig
- type Type
- type WithHandlerFunc
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidMetricOutputType = errors.New("invalid metrics output type")
)
Errors for the metrics package.
var (
ErrTimedOut = errors.New("timed out")
)
Errors for the HTTP type.
Functions ¶
func Descriptions ¶
func Descriptions() string
Descriptions returns a formatted string of collated descriptions of each type.
func SanitiseConfig ¶
SanitiseConfig returns a sanitised version of the Config, meaning sections that aren't relevant to behaviour are removed.
Types ¶
type Config ¶
type Config struct { Type string `json:"type" yaml:"type"` Prefix string `json:"prefix" yaml:"prefix"` HTTP struct{} `json:"http_server" yaml:"http_server"` Prometheus struct{} `json:"prometheus" yaml:"prometheus"` Riemann RiemannConfig `json:"riemann" yaml:"riemann"` Statsd StatsdConfig `json:"statsd" yaml:"statsd"` }
Config is the all encompassing configuration struct for all metric output types.
type DudType ¶
type DudType struct{}
DudType implements the Type interface but doesn't actual do anything.
type HTTP ¶
HTTP is an object with capability to hold internal stats as a JSON endpoint.
func (*HTTP) HandlerFunc ¶
func (h *HTTP) HandlerFunc() http.HandlerFunc
HandlerFunc returns an http.HandlerFunc for accessing metrics as a JSON blob.
type Prometheus ¶
type Prometheus struct {
// contains filtered or unexported fields
}
Prometheus is a stats object with capability to hold internal stats as a JSON endpoint.
func (*Prometheus) Close ¶
func (p *Prometheus) Close() error
Close stops the Prometheus object from aggregating metrics and cleans up resources.
func (*Prometheus) Decr ¶
func (p *Prometheus) Decr(stat string, value int64) error
Decr decrements a stat by a value.
func (*Prometheus) Gauge ¶
func (p *Prometheus) Gauge(stat string, value int64) error
Gauge sets a stat as a gauge value.
func (*Prometheus) HandlerFunc ¶
func (p *Prometheus) HandlerFunc() http.HandlerFunc
HandlerFunc returns an http.HandlerFunc for scraping metrics.
type PrometheusConfig ¶
type PrometheusConfig struct { }
PrometheusConfig is config for the Prometheus metrics type.
func NewPrometheusConfig ¶
func NewPrometheusConfig() PrometheusConfig
NewPrometheusConfig creates an PrometheusConfig struct with default values.
type Riemann ¶
Riemann is a Riemann client that supports the Type interface.
type RiemannConfig ¶
type RiemannConfig struct { Server string `json:"server" yaml:"server"` TTL float32 `json:"ttl" yaml:"ttl"` Tags []string `json:"tags" yaml:"tags"` FlushInterval string `json:"flush_interval" yaml:"flush_interval"` }
RiemannConfig contains configuration fields for a riemann service.
func NewRiemannConfig ¶
func NewRiemannConfig() RiemannConfig
NewRiemannConfig creates a new riemann config with default values.
type Statsd ¶
type Statsd struct {
// contains filtered or unexported fields
}
Statsd is a stats object with capability to hold internal stats as a JSON endpoint.
func (*Statsd) Close ¶
Close stops the Statsd object from aggregating metrics and cleans up resources.
type StatsdConfig ¶
type StatsdConfig struct { Address string `json:"address" yaml:"address"` FlushPeriod string `json:"flush_period" yaml:"flush_period"` MaxPacketSize int `json:"max_packet_size" yaml:"max_packet_size"` Network string `json:"network" yaml:"network"` }
StatsdConfig is config for the Statsd metrics type.
func NewStatsdConfig ¶
func NewStatsdConfig() StatsdConfig
NewStatsdConfig creates an StatsdConfig struct with default values.
type Type ¶
type Type interface { // Incr increments a metric by an amount. Incr(path string, count int64) error // Decr decrements a metric by an amount. Decr(path string, count int64) error // Timing sets a timing metric. Timing(path string, delta int64) error // Gauge sets a gauge metric. Gauge(path string, value int64) error // Close stops aggregating stats and clean up resources. Close() error }
Type is an interface for metrics aggregation.
func NewPrometheus ¶
NewPrometheus creates and returns a new Prometheus object.
func NewRiemann ¶
NewRiemann creates a new riemann client.
type WithHandlerFunc ¶
type WithHandlerFunc interface {
HandlerFunc() http.HandlerFunc
}
WithHandlerFunc is an interface for metrics types that can expose their metrics through an HTTP HandlerFunc endpoint. If a Type can be cast into WithHandlerFunc then you should register its endpoint to the an HTTP server.