Documentation ¶
Overview ¶
Package me3x package contains abstractions for reporting metrics to Graphite or Prometheus.
Index ¶
- Variables
- func ToString(value interface{}) string
- type AtomicFloat64
- type Counter
- type DummyRegistry
- type Gauge
- type GraphiteClient
- func (c *GraphiteClient) Close() error
- func (c *GraphiteClient) Counter(name string, labels Labels) Counter
- func (c *GraphiteClient) Flush() error
- func (c *GraphiteClient) FlushEvery(interval time.Duration)
- func (c *GraphiteClient) Gauge(name string, labels Labels) Gauge
- func (c *GraphiteClient) Histogram(name string, labels Labels, buckets []float64) Histogram
- func (c *GraphiteClient) WithPrefix(prefix string) Registry
- type GraphiteCounter
- type GraphiteGauge
- type GraphiteHistogram
- type GraphiteMetric
- type Histogram
- type Label
- type Labeled
- type Labels
- type PrometheusListener
- func (p *PrometheusListener) Close() error
- func (p *PrometheusListener) CloseWithContext(ctx context.Context) error
- func (p *PrometheusListener) Counter(name string, labels Labels) Counter
- func (p *PrometheusListener) Gauge(name string, labels Labels) Gauge
- func (p *PrometheusListener) Histogram(name string, labels Labels, buckets []float64) Histogram
- func (p *PrometheusListener) MustRegister(cs ...prometheus.Collector) *PrometheusListener
- func (p *PrometheusListener) WithPrefix(prefix string) Registry
- type Registry
Constants ¶
This section is empty.
Variables ¶
var GraphiteTimeout = 1 * time.Minute
GraphiteTimeout is the timeout for sending metrics to Graphite.
Functions ¶
Types ¶
type AtomicFloat64 ¶
type AtomicFloat64 uint64
AtomicFloat64 is an atomic float64 implementation.
func (*AtomicFloat64) Swap ¶
func (f *AtomicFloat64) Swap(value float64) float64
Swap updates the value and returns the old one.
type Counter ¶
type Counter interface { // Inc increments counter by 1. Inc() // Add adds delta to the counter. Add(delta float64) }
Counter is a simple metric which can be incremented.
type DummyRegistry ¶
type DummyRegistry struct { // Prefix is prefixed used for all metric names. Prefix string // Log should be set if metric call logging is desired. Log bool }
DummyRegistry is a dummy Registry implementation which does not store any metrics. Optionally may log calls.
func (DummyRegistry) Histogram ¶
func (r DummyRegistry) Histogram(name string, labels Labels, _ []float64) Histogram
func (DummyRegistry) WithPrefix ¶
func (r DummyRegistry) WithPrefix(prefix string) Registry
type Gauge ¶
type Gauge interface { // Set sets the current value. Set(value float64) // Inc increments current value by 1. Inc() // Dec decrements current value by 1. Dec() // Add adds delta to the current value. Add(delta float64) // Sub subtracts delta from the current value. Sub(delta float64) }
Gauge is a metric which value can be set.
type GraphiteClient ¶
type GraphiteClient struct { // Address is the address for sending metrics to. // See https://graphite.readthedocs.io/en/latest/feeding-carbon.html. Address string // Clock is used for getting timestamps when sending data. Clock syncf.Clock // HGBF is histogram bucket format. // It is a string pattern used to transform histogram bucket values into metric name suffix. HGBF string // contains filtered or unexported fields }
GraphiteClient is a Registry implementation for Graphite.
func (*GraphiteClient) Close ¶
func (c *GraphiteClient) Close() error
Close stops the goroutine if it was started
func (*GraphiteClient) Counter ¶
func (c *GraphiteClient) Counter(name string, labels Labels) Counter
func (*GraphiteClient) Flush ¶
func (c *GraphiteClient) Flush() error
Flush flushes metrics to Graphite.
func (*GraphiteClient) FlushEvery ¶ added in v0.10.5
func (c *GraphiteClient) FlushEvery(interval time.Duration)
FlushEvery starts a goroutine which flushes metrics from this GraphiteClient to the Graphite itself.
func (*GraphiteClient) Histogram ¶
func (c *GraphiteClient) Histogram(name string, labels Labels, buckets []float64) Histogram
func (*GraphiteClient) WithPrefix ¶
func (c *GraphiteClient) WithPrefix(prefix string) Registry
type GraphiteCounter ¶
type GraphiteCounter AtomicFloat64
GraphiteCounter is a Prometheus counter emulation.
func (*GraphiteCounter) Add ¶
func (c *GraphiteCounter) Add(delta float64)
func (*GraphiteCounter) Inc ¶
func (c *GraphiteCounter) Inc()
type GraphiteGauge ¶
type GraphiteGauge AtomicFloat64
GraphiteGauge is a Prometheus gauge emulation.
func (*GraphiteGauge) Add ¶
func (g *GraphiteGauge) Add(delta float64)
func (*GraphiteGauge) Dec ¶
func (g *GraphiteGauge) Dec()
func (*GraphiteGauge) Inc ¶
func (g *GraphiteGauge) Inc()
func (*GraphiteGauge) Set ¶
func (g *GraphiteGauge) Set(value float64)
func (*GraphiteGauge) Sub ¶
func (g *GraphiteGauge) Sub(delta float64)
type GraphiteHistogram ¶
type GraphiteHistogram struct {
// contains filtered or unexported fields
}
GraphiteHistogram is a Prometheus histogram emulation. This is a really primitive emulation.
func (GraphiteHistogram) Observe ¶
func (h GraphiteHistogram) Observe(value float64)
type GraphiteMetric ¶
type GraphiteMetric interface { // Write writes current metric value to Graphite, resetting the value if necessary. Write(b *strings.Builder, now string, key string) }
GraphiteMetric is a metric which can be sent to Graphite.
type Histogram ¶
type Histogram interface { // Observe registers a value within this Histogram. Observe(value float64) }
Histogram is a histogram metric.
type Labels ¶
type Labels []Label
Labels is the Label slice.
type PrometheusListener ¶
type PrometheusListener struct { Address string // contains filtered or unexported fields }
PrometheusListener is a Prometheus-based metric Registry.
func (*PrometheusListener) Close ¶
func (p *PrometheusListener) Close() error
func (*PrometheusListener) CloseWithContext ¶
func (p *PrometheusListener) CloseWithContext(ctx context.Context) error
func (*PrometheusListener) Counter ¶
func (p *PrometheusListener) Counter(name string, labels Labels) Counter
func (*PrometheusListener) Gauge ¶
func (p *PrometheusListener) Gauge(name string, labels Labels) Gauge
func (*PrometheusListener) Histogram ¶
func (p *PrometheusListener) Histogram(name string, labels Labels, buckets []float64) Histogram
func (*PrometheusListener) MustRegister ¶
func (p *PrometheusListener) MustRegister(cs ...prometheus.Collector) *PrometheusListener
func (*PrometheusListener) WithPrefix ¶
func (p *PrometheusListener) WithPrefix(prefix string) Registry
type Registry ¶
type Registry interface { // WithPrefix returns a copy of this Registry with the new sub-prefix // which will be applied to all of new Registry's metrics. WithPrefix(prefix string) Registry // Counter returns a Counter instance. // Labels are used depending on implementation. Counter(name string, labels Labels) Counter // Gauge returns a Gauge instance. // Labels are used depending on implementation. Gauge(name string, labels Labels) Gauge // Histogram returns a Histogram instance. // Labels are used depending on implementation. Histogram(name string, labels Labels, buckets []float64) Histogram }
Registry is an interface representing a named metric registry.