stats

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatisticsQueueKey = "statistics:%d"
	StateKey           = "state:%s:%s"
	KeyIdSep           = ":"
	IDTag              = "id"
)

Variables

View Source
var (
	Periods = []int64{300, 3600} //5 min, 1 hour
)

Functions

func NewLedisStatsAggregator

func NewLedisStatsAggregator(sink *transport.Sink) pm.StatsHandler

Types

type History

type History map[int64][]Sample

type Operation

type Operation string
const (
	Average      Operation = "A"
	Differential Operation = "D"

	HistoryLength = 5
)

type Point

type Point struct {
	*Sample
	Key  string            `json:"key"`
	Tags map[string]string `json:"tags,omitempty"`
}

type Sample

type Sample struct {
	Avg   float64 `json:"avg"`
	Total float64 `json:"total"`
	Max   float64 `json:"max"`
	Count uint    `json:"count"`
	Start int64   `json:"start"`
}

func (*Sample) Feed

func (m *Sample) Feed(value float64, now int64, duration int64) *Sample

Feed values on now, for the specific aggregate duration

type Samples

type Samples map[int64]*Sample

type State

type State struct {
	Operation Operation `json:"op"`
	LastValue float64   `json:"last_value"`
	LastTime  int64     `json:"last_time"`
	Tags      []pm.Tag  `json:"tags,omitempty"`
	Current   Samples   `json:"current"`
	History   History   `json:"history"`
}

func LoadState

func LoadState(data []byte) (*State, error)

func NewState

func NewState(op Operation, durations ...int64) *State

func (*State) Feed

func (s *State) Feed(value float64) Samples

func (*State) FeedOn

func (s *State) FeedOn(now int64, value float64) Samples

type Stats

type Stats struct {
	Operation Operation `json:"operation"`
	Key       string    `json:"key"`
	Value     float64   `json:"value"`
	Tags      []pm.Tag  `json:"tags"`
}

type Tags

type Tags []pm.Tag

func (Tags) Len

func (t Tags) Len() int

func (Tags) Less

func (t Tags) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (Tags) Swap

func (t Tags) Swap(i, j int)

Swap swaps the elements with indexes i and j.

Jump to

Keyboard shortcuts

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