statsmt

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: BSD-2-Clause-Views Imports: 18 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear()

func NewDevnull

func NewDevnull()

func NewGraphite

func NewGraphite(prefix, addr string, interval, bufferSize int, timeout time.Duration)

func WriteFloat64

func WriteFloat64(buf, prefix, key []byte, val float64, now time.Time) []byte

func WriteInt32

func WriteInt32(buf, prefix, key []byte, val int32, now time.Time) []byte

func WriteUint32

func WriteUint32(buf, prefix, key []byte, val uint32, now time.Time) []byte

func WriteUint64

func WriteUint64(buf, prefix, key []byte, val uint64, now time.Time) []byte

Types

type Bool

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

func NewBool

func NewBool(name string) *Bool

func (*Bool) Peek

func (b *Bool) Peek() bool

func (*Bool) ReportGraphite

func (b *Bool) ReportGraphite(prefix, buf []byte, now time.Time) []byte

func (*Bool) Set

func (b *Bool) Set(val bool)

func (*Bool) SetFalse

func (b *Bool) SetFalse()

func (*Bool) SetTrue

func (b *Bool) SetTrue()

type Counter32

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

func NewCounter32

func NewCounter32(name string) *Counter32

func (*Counter32) Add

func (c *Counter32) Add(val int)

func (*Counter32) AddUint32

func (c *Counter32) AddUint32(val uint32)

func (*Counter32) Inc

func (c *Counter32) Inc()

func (*Counter32) Peek

func (c *Counter32) Peek() uint32

func (*Counter32) ReportGraphite

func (c *Counter32) ReportGraphite(prefix, buf []byte, now time.Time) []byte

func (*Counter32) SetUint32

func (c *Counter32) SetUint32(val uint32)

type Counter64

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

func NewCounter64

func NewCounter64(name string) *Counter64

func (*Counter64) AddUint64

func (c *Counter64) AddUint64(val uint64)

func (*Counter64) Inc

func (c *Counter64) Inc()

func (*Counter64) ReportGraphite

func (c *Counter64) ReportGraphite(prefix, buf []byte, now time.Time) []byte

func (*Counter64) SetUint64

func (c *Counter64) SetUint64(val uint64)

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 NewGauge32(name string) *Gauge32

func (*Gauge32) Add

func (g *Gauge32) Add(val int)

func (*Gauge32) AddUint32

func (g *Gauge32) AddUint32(val uint32)

func (*Gauge32) Dec

func (g *Gauge32) Dec()

func (*Gauge32) DecUint32

func (g *Gauge32) DecUint32(val uint32)

func (*Gauge32) Inc

func (g *Gauge32) Inc()

func (*Gauge32) ReportGraphite

func (g *Gauge32) ReportGraphite(prefix, buf []byte, now time.Time) []byte

func (*Gauge32) Set

func (g *Gauge32) Set(val int)

func (*Gauge32) SetUint32

func (g *Gauge32) SetUint32(val uint32)

type Gauge64

type Gauge64 uint64

func NewGauge64

func NewGauge64(name string) *Gauge64

func (*Gauge64) Add

func (g *Gauge64) Add(val int)

func (*Gauge64) AddUint64

func (g *Gauge64) AddUint64(val uint64)

func (*Gauge64) Dec

func (g *Gauge64) Dec()

func (*Gauge64) DecUint64

func (g *Gauge64) DecUint64(val uint64)

func (*Gauge64) Inc

func (g *Gauge64) Inc()

func (*Gauge64) Peek

func (g *Gauge64) Peek() uint64

func (*Gauge64) ReportGraphite

func (g *Gauge64) ReportGraphite(prefix, buf []byte, now time.Time) []byte

func (*Gauge64) Set

func (g *Gauge64) Set(val int)

func (*Gauge64) SetUint64

func (g *Gauge64) SetUint64(val uint64)

type Graphite

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

type GraphiteMetric

type GraphiteMetric interface {
	// Report the measurements in graphite format and reset measurements for the next interval if needed
	ReportGraphite(prefix []byte, buf []byte, now time.Time) []byte
}

type Kafka

type Kafka map[int32]*KafkaPartition

Kafka tracks the health of a consumer

func NewKafka

func NewKafka(prefix string, partitions []int32) Kafka

type KafkaPartition

type KafkaPartition struct {
	Offset  Gauge64
	LogSize Gauge64
	Lag     Gauge64
}

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

type Meter32 struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewMeter32

func NewMeter32(name string, approx bool) *Meter32

func (*Meter32) ReportGraphite

func (m *Meter32) ReportGraphite(prefix, buf []byte, now time.Time) []byte

func (*Meter32) Value

func (m *Meter32) Value(val int)

func (*Meter32) ValueUint32

func (m *Meter32) ValueUint32(val uint32)

func (*Meter32) Values

func (m *Meter32) Values(val, num int)

func (*Meter32) ValuesUint32

func (m *Meter32) ValuesUint32(val, num uint32)

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

type Range32 struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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 NewRange32(name string) *Range32

func (*Range32) ReportGraphite

func (r *Range32) ReportGraphite(prefix, buf []byte, now time.Time) []byte

func (*Range32) Value

func (r *Range32) Value(val int)

func (*Range32) ValueUint32

func (r *Range32) ValueUint32(val uint32)

type Registry

type Registry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Registry tracks metrics and reporters

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Clear

func (r *Registry) Clear()

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)

Jump to

Keyboard shortcuts

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