graphite

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package graphite provides a Graphite backend for metrics. Metrics are batched and emitted in the plaintext protocol. For more information, see http://graphite.readthedocs.io/en/latest/feeding-carbon.html#the-plaintext-protocol

Graphite does not have a native understanding of metric parameterization, so label values not supported. Use distinct metrics for each unique combination of label values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter added in v0.3.0

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

Counter is a Graphite counter metric.

func NewCounter added in v0.3.0

func NewCounter(name string) *Counter

NewCounter returns a new usable counter metric.

func (*Counter) Add added in v0.3.0

func (c *Counter) Add(delta float64)

Add implements counter.

func (*Counter) With added in v0.3.0

func (c *Counter) With(...string) metrics.Counter

With is a no-op.

type Gauge added in v0.3.0

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

Gauge is a Graphite gauge metric.

func NewGauge added in v0.3.0

func NewGauge(name string) *Gauge

NewGauge returns a new usable Gauge metric.

func (*Gauge) Add added in v0.4.0

func (g *Gauge) Add(delta float64)

Add implements metrics.Gauge.

func (*Gauge) Set added in v0.3.0

func (g *Gauge) Set(value float64)

Set implements gauge.

func (*Gauge) With added in v0.3.0

func (g *Gauge) With(...string) metrics.Gauge

With is a no-op.

type Graphite added in v0.3.0

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

Graphite receives metrics observations and forwards them to a Graphite server. Create a Graphite object, use it to create metrics, and pass those metrics as dependencies to the components that will use them.

All metrics are buffered until WriteTo is called. Counters and gauges are aggregated into a single observation per timeseries per write. Histograms are exploded into per-quantile gauges and reported once per write.

To regularly report metrics to an io.Writer, use the WriteLoop helper method. To send to a Graphite server, use the SendLoop helper method.

func New added in v0.3.0

func New(prefix string, logger log.Logger) *Graphite

New returns a Graphite object that may be used to create metrics. Prefix is applied to all created metrics. Callers must ensure that regular calls to WriteTo are performed, either manually or with one of the helper methods.

func (*Graphite) NewCounter added in v0.3.0

func (g *Graphite) NewCounter(name string) *Counter

NewCounter returns a counter. Observations are aggregated and emitted once per write invocation.

func (*Graphite) NewGauge added in v0.3.0

func (g *Graphite) NewGauge(name string) *Gauge

NewGauge returns a gauge. Observations are aggregated and emitted once per write invocation.

func (*Graphite) NewHistogram added in v0.3.0

func (g *Graphite) NewHistogram(name string, buckets int) *Histogram

NewHistogram returns a histogram. Observations are aggregated and emitted as per-quantile gauges, once per write invocation. 50 is a good default value for buckets.

func (*Graphite) SendLoop added in v0.3.0

func (g *Graphite) SendLoop(ctx context.Context, c <-chan time.Time, network, address string)

SendLoop is a helper method that wraps WriteLoop, passing a managed connection to the network and address. Like WriteLoop, this method blocks until ctx is canceled, so clients probably want to start it in its own goroutine. For typical usage, create a time.Ticker and pass its C channel to this method.

func (*Graphite) WriteLoop added in v0.3.0

func (g *Graphite) WriteLoop(ctx context.Context, c <-chan time.Time, w io.Writer)

WriteLoop is a helper method that invokes WriteTo to the passed writer every time the passed channel fires. This method blocks until ctx is canceled, so clients probably want to run it in its own goroutine. For typical usage, create a time.Ticker and pass its C channel to this method.

func (*Graphite) WriteTo added in v0.3.0

func (g *Graphite) WriteTo(w io.Writer) (count int64, err error)

WriteTo flushes the buffered content of the metrics to the writer, in Graphite plaintext format. WriteTo abides best-effort semantics, so observations are lost if there is a problem with the write. Clients should be sure to call WriteTo regularly, ideally through the WriteLoop or SendLoop helper methods.

type Histogram added in v0.3.0

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

Histogram is a Graphite histogram metric. Observations are bucketed into per-quantile gauges.

func NewHistogram added in v0.3.0

func NewHistogram(name string, buckets int) *Histogram

NewHistogram returns a new usable Histogram metric.

func (*Histogram) Observe added in v0.3.0

func (h *Histogram) Observe(value float64)

Observe implements histogram.

func (*Histogram) With added in v0.3.0

func (h *Histogram) With(...string) metrics.Histogram

With is a no-op.

Jump to

Keyboard shortcuts

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