leaps: github.com/Jeffail/leaps/lib/util/service/metrics Index | Files

package metrics

import "github.com/Jeffail/leaps/lib/util/service/metrics"

Package metrics - Create a type for aggregating and propagating metrics to various services based on configuration. Use it like this:

“` go conf := metrics.NewConfig() conf.Type = "http_server"

met, err := metrics.New(conf) if err != nil {

panic(err)

}

met.Incr("path.to.metric", 1) “`

Index

Package Files

constructor.go dud_type.go http.go interface.go package.go riemann.go statsd.go

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.

func Descriptions Uses

func Descriptions() string

Descriptions - Returns a formatted string of collated descriptions of each type.

type Config Uses

type Config struct {
    Type    string        `json:"type" yaml:"type"`
    HTTP    HTTPConfig    `json:"http_server" yaml:"http_server"`
    Riemann RiemannConfig `json:"riemann" yaml:"riemann"`
    Statsd  StatsdConfig  `json:"statsd" yaml:"statsd"`
}

Config - The all encompassing configuration struct for all metric output types.

func NewConfig Uses

func NewConfig() Config

NewConfig - Returns a configuration struct fully populated with default values.

type DudType Uses

type DudType struct{}

DudType - Implements the Type interface but doesn't actual do anything.

func (DudType) Close Uses

func (d DudType) Close() error

Close - Does nothing.

func (DudType) Decr Uses

func (d DudType) Decr(path string, count int64) error

Decr - Does nothing.

func (DudType) Gauge Uses

func (d DudType) Gauge(path string, value int64) error

Gauge - Does nothing.

func (DudType) Incr Uses

func (d DudType) Incr(path string, count int64) error

Incr - Does nothing.

func (DudType) Timing Uses

func (d DudType) Timing(path string, delta int64) error

Timing - Does nothing.

type HTTP Uses

type HTTP struct {
    sync.Mutex
    // contains filtered or unexported fields
}

HTTP - A stats object with capability to hold internal stats as a JSON endpoint.

func (*HTTP) Close Uses

func (h *HTTP) Close() error

Close - Stops the HTTP object from aggregating metrics and cleans up resources.

func (*HTTP) Decr Uses

func (h *HTTP) Decr(stat string, value int64) error

Decr - Decrement a stat by a value.

func (*HTTP) Gauge Uses

func (h *HTTP) Gauge(stat string, value int64) error

Gauge - Set a stat as a gauge value.

func (*HTTP) Incr Uses

func (h *HTTP) Incr(stat string, value int64) error

Incr - Increment a stat by a value.

func (*HTTP) JSONHandler Uses

func (h *HTTP) JSONHandler() http.HandlerFunc

JSONHandler - Returns a handler for accessing metrics as a JSON blob.

func (*HTTP) Timing Uses

func (h *HTTP) Timing(stat string, delta int64) error

Timing - Set a stat representing a duration.

type HTTPConfig Uses

type HTTPConfig struct {
    Prefix  string `json:"stats_prefix" yaml:"stats_prefix"`
    Address string `json:"address" yaml:"address"`
    Path    string `json:"path" yaml:"path"`
}

HTTPConfig - Config for the HTTP metrics type.

func NewHTTPConfig Uses

func NewHTTPConfig() HTTPConfig

NewHTTPConfig - Creates an HTTPConfig struct with default values.

type Riemann Uses

type Riemann struct {
    sync.Mutex

    Client *raidman.Client
    // contains filtered or unexported fields
}

Riemann - A Riemann client that supports the Type interface.

func (*Riemann) Close Uses

func (r *Riemann) Close() error

Close - Close the riemann client and stop batch uploading.

func (*Riemann) Decr Uses

func (r *Riemann) Decr(stat string, value int64) error

Decr - Decrement a stat by a value.

func (*Riemann) Gauge Uses

func (r *Riemann) Gauge(stat string, value int64) error

Gauge - Set a stat as a gauge value.

func (*Riemann) Incr Uses

func (r *Riemann) Incr(stat string, value int64) error

Incr - Increment a stat by a value.

func (*Riemann) Timing Uses

func (r *Riemann) Timing(stat string, delta int64) error

Timing - Set a stat representing a duration.

type RiemannConfig Uses

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"`
    Prefix        string   `json:"prefix" yaml:"prefix"`
}

RiemannConfig - Configuration fields for a riemann service.

func NewRiemannConfig Uses

func NewRiemannConfig() RiemannConfig

NewRiemannConfig - Create a new riemann config with default values.

type Statsd Uses

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

Statsd - A stats object with capability to hold internal stats as a JSON endpoint.

func (*Statsd) Close Uses

func (h *Statsd) Close() error

Close - Stops the Statsd object from aggregating metrics and cleans up resources.

func (*Statsd) Decr Uses

func (h *Statsd) Decr(stat string, value int64) error

Decr - Decrement a stat by a value.

func (*Statsd) Gauge Uses

func (h *Statsd) Gauge(stat string, value int64) error

Gauge - Set a stat as a gauge value.

func (*Statsd) Incr Uses

func (h *Statsd) Incr(stat string, value int64) error

Incr - Increment a stat by a value.

func (*Statsd) Timing Uses

func (h *Statsd) Timing(stat string, delta int64) error

Timing - Set a stat representing a duration.

type StatsdConfig Uses

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"`
    Prefix        string `json:"prefix" yaml:"prefix"`
}

StatsdConfig - Config for the Statsd metrics type.

func NewStatsdConfig Uses

func NewStatsdConfig() StatsdConfig

NewStatsdConfig - Creates an StatsdConfig struct with default values.

type Type Uses

type Type interface {
    // Incr - Increment a metric by an amount.
    Incr(path string, count int64) error

    // Decr - Decrement a metric by an amount.
    Decr(path string, count int64) error

    // Timing - Set a timing metric.
    Timing(path string, delta int64) error

    // Gauge - Set a gauge metric.
    Gauge(path string, value int64) error

    // Close - Stop aggregating stats and clean up resources.
    Close() error
}

Type - An interface for metrics aggregation.

func New Uses

func New(conf Config) (Type, error)

New - Create a metric output type based on a configuration.

func NewHTTP Uses

func NewHTTP(config Config) (Type, error)

NewHTTP - Create and return a new HTTP object.

func NewRiemann Uses

func NewRiemann(config Config) (Type, error)

NewRiemann - Create a new riemann client.

func NewStatsd Uses

func NewStatsd(config Config) (Type, error)

NewStatsd - Create and return a new Statsd object.

Package metrics imports 12 packages (graph) and is imported by 3 packages. Updated 2018-02-20. Refresh now. Tools for package owners.