graphite

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package graphite implements a Graphite backend for package metrics. Metrics will be emitted to a Graphite server in the plaintext protocol which looks like:

"<metric path> <metric value> <metric timestamp>"

See http://graphite.readthedocs.io/en/latest/feeding-carbon.html#the-plaintext-protocol. The current implementation ignores fields.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emitter

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

Emitter is a struct to manage connections and orchestrate the emission of metrics to a Graphite system.

func NewEmitter

func NewEmitter(network, address string, metricsPrefix string, flushInterval time.Duration, logger log.Logger) *Emitter

NewEmitter will return an Emitter that will prefix all metrics names with the given prefix. Once started, it will attempt to create a connection with the given network and address via `net.Dial` and periodically post metrics to the connection in the Graphite plaintext protocol.

func NewEmitterDial

func NewEmitterDial(dialer conn.Dialer, network, address string, metricsPrefix string, flushInterval time.Duration, logger log.Logger) *Emitter

NewEmitterDial is the same as NewEmitter, but allows you to specify your own Dialer function. This is primarily useful for tests.

func (*Emitter) Flush

func (e *Emitter) Flush()

Flush will write the current metrics to the Emitter's connection in the Graphite plaintext protocol.

func (*Emitter) NewCounter

func (e *Emitter) NewCounter(name string) metrics.Counter

NewCounter returns a Counter whose value will be periodically emitted in a Graphite-compatible format once the Emitter is started. Fields are ignored.

func (*Emitter) NewGauge

func (e *Emitter) NewGauge(name string) metrics.Gauge

NewGauge returns a Gauge whose value will be periodically emitted in a Graphite-compatible format once the Emitter is started. Fields are ignored.

func (*Emitter) NewHistogram

func (e *Emitter) NewHistogram(name string, minValue, maxValue int64, sigfigs int, quantiles ...int) (metrics.Histogram, error)

NewHistogram is taken from http://github.com/codahale/metrics. It returns a windowed HDR histogram which drops data older than five minutes.

The histogram exposes metrics for each passed quantile as gauges. Quantiles should be integers in the range 1..99. The gauge names are assigned by using the passed name as a prefix and appending "_pNN" e.g. "_p50".

The values of this histogram will be periodically emitted in a Graphite-compatible format once the Emitter is started. Fields are ignored.

func (*Emitter) Stop

func (e *Emitter) Stop()

Stop will flush the current metrics and close the active connection. Calling stop more than once is a programmer error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL