Import path:
gitlab.soludian.com/soludian/fountain/libs/metrics/graphite
graphite
import "gitlab.soludian.com/soludian/fountain/libs/metrics/graphite"Index
- Variables
- type Counter
- type Gauge
- type Graphite
- func New(prefix string, logger flog.FlogInf) *Graphite
- func (g *Graphite) NewCounter(name string) *Counter
- func (g *Graphite) NewGauge(name string) *Gauge
- func (g *Graphite) NewHistogram(name string, buckets int) *Histogram
- func (g *Graphite) SendLoop(ctx context.Context, c <-chan time.Time, network, address string)
- func (g *Graphite) WriteLoop(ctx context.Context, c <-chan time.Time, w io.Writer)
- func (g *Graphite) WriteTo(w io.Writer) (count int64, err error)
- type Histogram
Variables
var KPackageName = "graphite"type Counter
Counter is a Graphite counter metric.
type Counter struct {
// contains filtered or unexported fields
}func NewCounter
func NewCounter(name string) *CounterNewCounter returns a new usable counter metric.
func (*Counter) Add
func (c *Counter) Add(delta float64)Add implements counter.
func (*Counter) With
func (c *Counter) With(...string) metrics.CounterWith is a no-op.
type Gauge
Gauge is a Graphite gauge metric.
type Gauge struct {
// contains filtered or unexported fields
}func NewGauge
func NewGauge(name string) *GaugeNewGauge returns a new usable Gauge metric.
func (*Gauge) Add
func (g *Gauge) Add(delta float64)Add implements metrics.Gauge.
func (*Gauge) Set
func (g *Gauge) Set(value float64)Set implements gauge.
func (*Gauge) With
func (g *Gauge) With(...string) metrics.GaugeWith is a no-op.
type Graphite
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 time series 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.
type Graphite struct {
// contains filtered or unexported fields
}func New
func New(prefix string, logger flog.FlogInf) *GraphiteNew 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
func (g *Graphite) NewCounter(name string) *CounterNewCounter returns a counter. Observations are aggregated and emitted once per write invocation.
func (*Graphite) NewGauge
func (g *Graphite) NewGauge(name string) *GaugeNewGauge returns a gauge. Observations are aggregated and emitted once per write invocation.
func (*Graphite) NewHistogram
func (g *Graphite) NewHistogram(name string, buckets int) *HistogramNewHistogram 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
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
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
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
Histogram is a Graphite histogram metric. Observations are bucketed into per-quantile gauges.
type Histogram struct {
// contains filtered or unexported fields
}func NewHistogram
func NewHistogram(name string, buckets int) *HistogramNewHistogram returns a new usable Histogram metric.
func (*Histogram) Observe
func (h *Histogram) Observe(value float64)Observe implements histogram.
func (*Histogram) With
func (h *Histogram) With(...string) metrics.HistogramWith is a no-op.
Generated by gomarkdoc