Documentation ¶
Overview ¶
Package stats provides functionality for instrumenting metrics and reporting them
The metrics can be user specified, or sourced from the runtime (reporters) To use this package correctly, you must instantiate exactly 1 output. If you use 0 outputs, certain metrics type will accumulate data unboundedly (e.g. histograms and meters) resulting in unreasonable memory usage. (though you can ignore this for shortlived processes, unit tests, etc) If you use >1 outputs, then each will only see a partial view of the stats. Currently supported outputs are DevNull and Graphite
Index ¶
- func Clear()
- func NewDevnull()
- func NewGraphite(prefix, addr string, interval, bufferSize int, timeout time.Duration)
- func WriteFloat64(buf, prefix, key []byte, val float64, now time.Time) []byte
- func WriteInt32(buf, prefix, key []byte, val int32, now time.Time) []byte
- func WriteUint32(buf, prefix, key []byte, val uint32, now time.Time) []byte
- func WriteUint64(buf, prefix, key []byte, val uint64, now time.Time) []byte
- type Bool
- type Counter32
- type Counter64
- type CounterRate32
- type Gauge32
- func (g *Gauge32) Add(val int)
- func (g *Gauge32) AddUint32(val uint32)
- func (g *Gauge32) Dec()
- func (g *Gauge32) DecUint32(val uint32)
- func (g *Gauge32) Inc()
- func (g *Gauge32) ReportGraphite(prefix, buf []byte, now time.Time) []byte
- func (g *Gauge32) Set(val int)
- func (g *Gauge32) SetUint32(val uint32)
- type Gauge64
- func (g *Gauge64) Add(val int)
- func (g *Gauge64) AddUint64(val uint64)
- func (g *Gauge64) Dec()
- func (g *Gauge64) DecUint64(val uint64)
- func (g *Gauge64) Inc()
- func (g *Gauge64) Peek() uint64
- func (g *Gauge64) ReportGraphite(prefix, buf []byte, now time.Time) []byte
- func (g *Gauge64) Set(val int)
- func (g *Gauge64) SetUint64(val uint64)
- type Graphite
- type GraphiteMetric
- type Kafka
- type KafkaPartition
- type LatencyHistogram12h32
- type LatencyHistogram15s32
- type MemoryReporter
- type Meter32
- type ProcessReporter
- type Range32
- type Registry
- type TimeDiffReporter32
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDevnull ¶
func NewDevnull()
func NewGraphite ¶
Types ¶
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
func (*Bool) ReportGraphite ¶
type Counter32 ¶
type Counter32 struct {
// contains filtered or unexported fields
}
func NewCounter32 ¶
func (*Counter32) ReportGraphite ¶
type Counter64 ¶
type Counter64 struct {
// contains filtered or unexported fields
}
func NewCounter64 ¶
func (*Counter64) ReportGraphite ¶
type CounterRate32 ¶
type CounterRate32 struct {
// contains filtered or unexported fields
}
CounterRate32 publishes a counter32 as well as a rate32 in seconds
func NewCounterRate32 ¶
func NewCounterRate32(name string) *CounterRate32
func (*CounterRate32) Add ¶
func (c *CounterRate32) Add(val int)
func (*CounterRate32) AddUint32 ¶
func (c *CounterRate32) AddUint32(val uint32)
func (*CounterRate32) Inc ¶
func (c *CounterRate32) Inc()
func (*CounterRate32) Peek ¶
func (c *CounterRate32) Peek() uint32
func (*CounterRate32) ReportGraphite ¶
func (c *CounterRate32) ReportGraphite(prefix, buf []byte, now time.Time) []byte
func (*CounterRate32) SetUint32 ¶
func (c *CounterRate32) SetUint32(val uint32)
type Gauge32 ¶
type Gauge32 struct {
// contains filtered or unexported fields
}
func NewGauge32 ¶
func (*Gauge32) ReportGraphite ¶
type GraphiteMetric ¶
type KafkaPartition ¶
KafkaPartition tracks the health of a partition consumer
func NewKafkaPartition ¶
func NewKafkaPartition(prefix string) *KafkaPartition
type LatencyHistogram12h32 ¶
type LatencyHistogram12h32 struct {
// contains filtered or unexported fields
}
tracks latency measurements in a given range as 32 bit counters
func NewLatencyHistogram12h32 ¶
func NewLatencyHistogram12h32(name string) *LatencyHistogram12h32
func (*LatencyHistogram12h32) ReportGraphite ¶
func (l *LatencyHistogram12h32) ReportGraphite(prefix, buf []byte, now time.Time) []byte
func (*LatencyHistogram12h32) Value ¶
func (l *LatencyHistogram12h32) Value(t time.Duration)
type LatencyHistogram15s32 ¶
type LatencyHistogram15s32 struct {
// contains filtered or unexported fields
}
tracks latency measurements in a given range as 32 bit counters
func NewLatencyHistogram15s32 ¶
func NewLatencyHistogram15s32(name string) *LatencyHistogram15s32
func (*LatencyHistogram15s32) ReportGraphite ¶
func (l *LatencyHistogram15s32) ReportGraphite(prefix, buf []byte, now time.Time) []byte
func (*LatencyHistogram15s32) Value ¶
func (l *LatencyHistogram15s32) Value(t time.Duration)
type MemoryReporter ¶
type MemoryReporter struct {
// contains filtered or unexported fields
}
MemoryReporter sources memory stats from the runtime and reports them It also reports gcPercent based on the GOGC environment variable
func NewMemoryReporter ¶
func NewMemoryReporter() *MemoryReporter
func (*MemoryReporter) ReportGraphite ¶
func (m *MemoryReporter) ReportGraphite(prefix, buf []byte, now time.Time) []byte
type Meter32 ¶
func NewMeter32 ¶
func (*Meter32) ReportGraphite ¶
func (*Meter32) ValueUint32 ¶
func (*Meter32) ValuesUint32 ¶
type ProcessReporter ¶
type ProcessReporter struct {
// contains filtered or unexported fields
}
ProcessReporter sources stats from /proc
func NewProcessReporter ¶
func NewProcessReporter() (*ProcessReporter, error)
func (*ProcessReporter) ReportGraphite ¶
func (m *ProcessReporter) ReportGraphite(prefix, buf []byte, now time.Time) []byte
type Range32 ¶
Range32 computes the min and max of sets of numbers, as 32bit numbers example application: queue depths min lets you see if the queue is able to drain max lets you see how large the queue tends to grow concurrency-safe
func NewRange32 ¶
func (*Range32) ReportGraphite ¶
func (*Range32) ValueUint32 ¶
type Registry ¶
Registry tracks metrics and reporters
func NewRegistry ¶
func NewRegistry() *Registry
type TimeDiffReporter32 ¶
type TimeDiffReporter32 struct {
// contains filtered or unexported fields
}
reports the time in seconds until a specific timestamp is reached once reached, reports 0
func NewTimeDiffReporter32 ¶
func NewTimeDiffReporter32(name string, target uint32) *TimeDiffReporter32
func (*TimeDiffReporter32) ReportGraphite ¶
func (g *TimeDiffReporter32) ReportGraphite(prefix, buf []byte, now time.Time) []byte
func (*TimeDiffReporter32) Set ¶
func (g *TimeDiffReporter32) Set(target uint32)