Import path:
gitlab.soludian.com/soludian/fountain/libs/metrics/influx_stats_d
influx_stats_d
import "gitlab.soludian.com/soludian/fountain/libs/metrics/influx_stats_d"Index
- Variables
- type Counter
- type Gauge
- type Histogram
- type InfluxStatsD
- func New(prefix string, logger flog.FlogInf, lvs ...string) *InfluxStatsD
- func (d *InfluxStatsD) NewCounter(name string, sampleRate float64) *Counter
- func (d *InfluxStatsD) NewGauge(name string) *Gauge
- func (d *InfluxStatsD) NewHistogram(name string, sampleRate float64) *Histogram
- func (d *InfluxStatsD) NewTiming(name string, sampleRate float64) *Timing
- func (d *InfluxStatsD) SendLoop(ctx context.Context, c <-chan time.Time, network, address string)
- func (d *InfluxStatsD) WriteLoop(ctx context.Context, c <-chan time.Time, w io.Writer)
- func (d *InfluxStatsD) WriteTo(w io.Writer) (count int64, err error)
- type Timing
Variables
var KPackageName = "influx_stats_d"type Counter
Counter is a InfluxStatsD counter. Observations are forwarded to a InfluxStatsD object, and aggregated (summed) per time series.
type Counter struct {
// contains filtered or unexported fields
}func (*Counter) Add
func (c *Counter) Add(delta float64)Add implements metrics.Counter.
func (*Counter) With
func (c *Counter) With(labelValues ...string) metrics.CounterWith implements metrics.Counter.
type Gauge
Gauge is a InfluxStatsD gauge. Observations are forwarded to a InfluxStatsD object, and aggregated (the last observation selected) per time series.
type Gauge struct {
// contains filtered or unexported fields
}func (*Gauge) Add
func (g *Gauge) Add(delta float64)Add implements metrics.Gauge.
func (*Gauge) Set
func (g *Gauge) Set(value float64)Set implements metrics.Gauge.
func (*Gauge) With
func (g *Gauge) With(labelValues ...string) metrics.GaugeWith implements metrics.Gauge.
type Histogram
Histogram is a InfluxStatsD histrogram. Observations are forwarded to a InfluxStatsD object, and collected (but not aggregated) per time series.
type Histogram struct {
// contains filtered or unexported fields
}func (*Histogram) Observe
func (h *Histogram) Observe(value float64)Observe implements metrics.Histogram.
func (*Histogram) With
func (h *Histogram) With(labelValues ...string) metrics.HistogramWith implements metrics.Histogram.
type InfluxStatsD
InfluxStatsD receives metrics observations and forwards them to a server. Create a InfluxStatsD 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. Timings and histograms are buffered but not aggregated.
To regularly report metrics to an io.Writer, use the WriteLoop helper method. To send to a InfluxStatsD server, use the SendLoop helper method.
type InfluxStatsD struct {
// contains filtered or unexported fields
}func New
func New(prefix string, logger flog.FlogInf, lvs ...string) *InfluxStatsDNew returns a InfluxStatsD 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 (*InfluxStatsD) NewCounter
func (d *InfluxStatsD) NewCounter(name string, sampleRate float64) *CounterNewCounter returns a counter, sending observations to this InfluxStatsD object.
func (*InfluxStatsD) NewGauge
func (d *InfluxStatsD) NewGauge(name string) *GaugeNewGauge returns a gauge, sending observations to this InfluxStatsD object.
func (*InfluxStatsD) NewHistogram
func (d *InfluxStatsD) NewHistogram(name string, sampleRate float64) *HistogramNewHistogram returns a histogram whose observations are of an unspecified unit, and are forwarded to this InfluxStatsD object.
func (*InfluxStatsD) NewTiming
func (d *InfluxStatsD) NewTiming(name string, sampleRate float64) *TimingNewTiming returns a histogram whose observations are interpreted as millisecond durations, and are forwarded to this InfluxStatsD object.
func (*InfluxStatsD) SendLoop
func (d *InfluxStatsD) 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 (*InfluxStatsD) WriteLoop
func (d *InfluxStatsD) 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 (*InfluxStatsD) WriteTo
func (d *InfluxStatsD) WriteTo(w io.Writer) (count int64, err error)WriteTo flushes the buffered content of the metrics to the writer, in InfluxStatsD 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 Timing
Timing is a InfluxStatsD timing, or metrics.Histogram. Observations are forwarded to a InfluxStatsD object, and collected (but not aggregated) per time series.
type Timing struct {
// contains filtered or unexported fields
}func (*Timing) Observe
func (t *Timing) Observe(value float64)Observe implements metrics.Histogram. Value is interpreted as milliseconds.
func (*Timing) With
func (t *Timing) With(labelValues ...string) metrics.HistogramWith implements metrics.Timing.
Generated by gomarkdoc