Documentation ¶
Index ¶
- Constants
- func Aggregate(conn io.Reader, numReceivers int) (snapchan chan *Snapshot)
- func LogTo(out io.Writer)
- func LogToSyslog()
- func ParseFloat(b []byte) (f float64, e error)
- func RunReceiver(id string, conn io.Reader, notifiers ...chan Statgram) (controlChannel chan *Snapshot)
- func ServeStatus(server *Server) error
- type CountBucket
- type CountLevel
- type FlagFile
- type FrequencyCount
- type FrequencyCountSlice
- type FrequencyCounter
- type Graphite
- type GraphiteDialer
- type Harold
- type HaroldPoster
- type LineReader
- type MultilevelCount
- type Receiver
- type ReportedValue
- type Sample
- type SampleType
- type Server
- type Snapshot
- func (snapshot *Snapshot) Aggregate(child *Snapshot)
- func (snapshot *Snapshot) Count(key string, value float64)
- func (snapshot *Snapshot) CountString(key, value string, count float64)
- func (snapshot *Snapshot) Flush()
- func (snapshot *Snapshot) GraphiteReport() (report []string)
- func (snapshot *Snapshot) NumStats() int
- func (snapshot *Snapshot) ProcessStatgram(statgram Statgram)
- func (snapshot *Snapshot) Report(key string, value float64, ts ...time.Time)
- func (snapshot *Snapshot) Time(key string, value float64)
- type Statgram
- type StatgramParser
- type StatusRequest
- type SyntaxError
Constants ¶
const MAX_LINE_LEN = 1024
const (
STATGRAM_MAXSIZE = 10240
)
const STRING_COUNT_CAPACITY = 1024
const TIMINGS_INITIAL_CAPACITY = 1024
Variables ¶
This section is empty.
Functions ¶
func Aggregate ¶
Aggregate spins off receivers and a goroutine to manage them. Returns a channel to coordinate the collection of snapshots from the receivers.
func LogToSyslog ¶
func LogToSyslog()
func RunReceiver ¶
func RunReceiver(id string, conn io.Reader, notifiers ...chan Statgram) (controlChannel chan *Snapshot)
RunReceiver spins off a goroutine to receive and process statgrams. Returns a bidirectional control channel, which provides a snapshot each time it's given a nil value.
An optional channel for notification of processed statgrams may be passed in to facilitate testing.
func ServeStatus ¶
Types ¶
type CountBucket ¶
type CountBucket struct {
// contains filtered or unexported fields
}
func (*CountBucket) String ¶
func (b *CountBucket) String() string
type CountLevel ¶
type CountLevel struct { Current float64 // contains filtered or unexported fields }
func (*CountLevel) Count ¶
func (lvl *CountLevel) Count(value float64)
func (*CountLevel) Duration ¶
func (lvl *CountLevel) Duration() time.Duration
func (*CountLevel) NewBucket ¶
func (lvl *CountLevel) NewBucket()
func (*CountLevel) Reset ¶
func (lvl *CountLevel) Reset()
type FlagFile ¶
func NewFlagFile ¶
type FrequencyCount ¶
type FrequencyCount struct {
// contains filtered or unexported fields
}
type FrequencyCountSlice ¶
type FrequencyCountSlice []FrequencyCount
func (FrequencyCountSlice) Len ¶
func (fcs FrequencyCountSlice) Len() int
func (FrequencyCountSlice) Less ¶
func (fcs FrequencyCountSlice) Less(i, j int) bool
func (FrequencyCountSlice) Swap ¶
func (fcs FrequencyCountSlice) Swap(i, j int)
type FrequencyCounter ¶
type FrequencyCounter struct {
// contains filtered or unexported fields
}
func NewFrequencyCounter ¶
func NewFrequencyCounter(capacity int, intervals ...time.Duration) *FrequencyCounter
func (*FrequencyCounter) Aggregate ¶
func (fcr *FrequencyCounter) Aggregate(child *FrequencyCounter)
func (*FrequencyCounter) Count ¶
func (fcr *FrequencyCounter) Count(key string, count float64)
func (*FrequencyCounter) SortedItems ¶
func (fcr *FrequencyCounter) SortedItems() FrequencyCountSlice
func (*FrequencyCounter) Trim ¶
func (fcr *FrequencyCounter) Trim()
type Graphite ¶
type Graphite struct {
// contains filtered or unexported fields
}
Graphite is a client for sending stat reports to a graphite (carbon) server.
func NewGraphite ¶
func (*Graphite) SendReport ¶
SendReport takes a snapshot and submits all its stats to graphite.
type GraphiteDialer ¶
type GraphiteDialer interface {
Dial(*net.TCPAddr) (io.WriteCloser, error)
}
type Harold ¶
type Harold struct {
// contains filtered or unexported fields
}
Harold is a monitoring service used by reddit. We post heartbeat messages to harold to let it know we're alive. See more at https://github.com/spladug/harold.
func (*Harold) HeartMonitor ¶
HeartMonitor returns a channel for the caller to send harold heartbeats to. It spins off a goroutine so the heartbeat channel never blocks, even if the harold service is not responding.
type HaroldPoster ¶
type LineReader ¶
type MultilevelCount ¶
type MultilevelCount []CountLevel
func NewMultilevelCount ¶
func NewMultilevelCount(intervals ...time.Duration) *MultilevelCount
func (MultilevelCount) Count ¶
func (mc MultilevelCount) Count(value float64)
func (MultilevelCount) Reset ¶
func (mc MultilevelCount) Reset()
func (MultilevelCount) Rollup ¶
func (mc MultilevelCount) Rollup()
func (MultilevelCount) Total ¶
func (mc MultilevelCount) Total() float64
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receivers share the work of listening on a UDP port and accumulating stats.
func NewReceiver ¶
func NewReceiver() *Receiver
func (*Receiver) ReadOnce ¶
ReadOnce blocks on the listening connection until a statgram arrives. It takes care of parsing it and returns it. Any parse errors are ignored, so it's possible an empty statgram will be returned.
func (*Receiver) ReceiveStatgrams ¶
ReceiveStatgrams spins off a goroutine to read statgrams off the UDP port. Returns a buffered channel that will receive statgrams as they arrive.
type ReportedValue ¶
type ReportedValue struct {
// contains filtered or unexported fields
}
type Sample ¶
type Sample struct {
// contains filtered or unexported fields
}
func ParseSample ¶
ParseSample decodes a formatted string encoding a sampled value. Sampled values are either counts or timings, and are also associated with a sample rate. The format is: <VALUE> '|' <TYPECODE> ['@' <SAMPLE_RATE>] ['|' <ENC_STRING>] The <VALUE> and optional <SAMPLE_RATE> tokens are floating point decimals. If the sample rate annotation isn't present, then it's assumed to be 1.0 (100%). The <TYPECODE> token is either 'c', 'ms', or 's', indicating a counter value, timer value, or string count respectively. In the case of a string count, the string being counted may be given via <ENC_STRING> (where special characters such as '\', '|', ':', and the newline are escaped).
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
func NewSnapshot ¶
func NewSnapshot() *Snapshot
func (*Snapshot) CountString ¶
func (*Snapshot) GraphiteReport ¶
func (*Snapshot) ProcessStatgram ¶
ProcessStatgram accumulates a statistic report into the current snapshot.
type StatgramParser ¶
func NewStatgramParser ¶
func NewStatgramParser() *StatgramParser
func (*StatgramParser) ParseStatgram ¶
func (parser *StatgramParser) ParseStatgram(datagram []byte) Statgram
ParseStatgram reads samples from the given text, returning a Statgram. The format of a statgram is line-oriented. Each line names a key and provides one or more sampled values for that key. The documentation for the ParseStatgramLine function explains the formatting of each line.
func (*StatgramParser) ParseStatgramLine ¶
func (parser *StatgramParser) ParseStatgramLine(line []byte) (s Statgram, err error)
ParseStatgramLine reads samples from one line of a statgram. This line provides a key name and one or more sampled values for that key. The key name and each of the values are separated by the ':' character. The format for each sampled value is explained in the documentation for ParseSample.
type StatusRequest ¶
type StatusRequest struct {
// contains filtered or unexported fields
}
type SyntaxError ¶
type SyntaxError struct {
// contains filtered or unexported fields
}
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string