tally

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2015 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_LINE_LEN = 1024
View Source
const (
	STATGRAM_MAXSIZE = 10240
)
View Source
const STRING_COUNT_CAPACITY = 1024
View Source
const TIMINGS_INITIAL_CAPACITY = 1024

Variables

This section is empty.

Functions

func Aggregate

func Aggregate(conn io.Reader, numReceivers int) (snapchan chan *Snapshot)

Aggregate spins off receivers and a goroutine to manage them. Returns a channel to coordinate the collection of snapshots from the receivers.

func LogTo

func LogTo(out io.Writer)

func LogToSyslog

func LogToSyslog()

func ParseFloat

func ParseFloat(b []byte) (f float64, e error)

b must be NUL-terminated

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

func ServeStatus(server *Server) error

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) RatePer

func (lvl *CountLevel) RatePer(unit time.Duration) float64

func (*CountLevel) Reset

func (lvl *CountLevel) Reset()

type FlagFile

type FlagFile struct {
	*flag.FlagSet
}

func NewFlagFile

func NewFlagFile(path string) (ff *FlagFile, err error)

func (*FlagFile) ReadFlags

func (ff *FlagFile) ReadFlags(reader io.Reader) error

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 NewGraphite(address string,
	options ...interface{}) (client *Graphite, err error)

func (*Graphite) Dial

func (graphite *Graphite) Dial(addr *net.TCPAddr) (io.WriteCloser, error)

func (*Graphite) SendReport

func (graphite *Graphite) SendReport(snapshot *Snapshot) (err error)

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 NewHarold

func NewHarold(address string, secret string,
	options ...interface{}) (harold *Harold, err error)

func (*Harold) HeartMonitor

func (harold *Harold) HeartMonitor(tag string) (intervals chan time.Duration)

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.

func (*Harold) Heartbeat

func (harold *Harold) Heartbeat(tag string,
	interval time.Duration) (*http.Response, error)

Heartbeat sends a heartbeat message to harold, blocking until acknowledged.

func (*Harold) Post

func (harold *Harold) Post(path []string,
	data map[string]string) (*http.Response, error)

type HaroldPoster

type HaroldPoster interface {
	Post(path []string, data map[string]string) (*http.Response, error)
}

type LineReader

type LineReader interface {
	ReadLine() ([]byte, bool, error)
}

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

func (receiver *Receiver) ReadOnce() (s Statgram, err error)

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

func (receiver *Receiver) ReceiveStatgrams() (statgrams chan Statgram)

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

func ParseSample(key string, part []byte) (sample Sample, err error)

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 SampleType

type SampleType int
const (
	COUNTER SampleType = iota
	TIMER
	STRING
)

type Server

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

func NewServer

func NewServer(host string, port int, numWorkers int,
	flushInterval time.Duration, graphite *Graphite, harold *Harold) *Server

func (*Server) Loop

func (server *Server) Loop() error

type Snapshot

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

func NewSnapshot

func NewSnapshot() *Snapshot

func (*Snapshot) Aggregate

func (snapshot *Snapshot) Aggregate(child *Snapshot)

func (*Snapshot) Count

func (snapshot *Snapshot) Count(key string, value float64)

func (*Snapshot) CountString

func (snapshot *Snapshot) CountString(key, value string, count float64)

func (*Snapshot) Flush

func (snapshot *Snapshot) Flush()

func (*Snapshot) GraphiteReport

func (snapshot *Snapshot) GraphiteReport() (report []string)

func (*Snapshot) NumStats

func (snapshot *Snapshot) NumStats() int

func (*Snapshot) ProcessStatgram

func (snapshot *Snapshot) ProcessStatgram(statgram Statgram)

ProcessStatgram accumulates a statistic report into the current snapshot.

func (*Snapshot) Report

func (snapshot *Snapshot) Report(key string, value float64, ts ...time.Time)

func (*Snapshot) Time

func (snapshot *Snapshot) Time(key string, value float64)

type Statgram

type Statgram []Sample

type StatgramParser

type StatgramParser struct {
	Statgram
	Length int
	// contains filtered or unexported fields
}

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

Jump to

Keyboard shortcuts

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