stats

package
v0.0.0-...-9bd2c4f Latest Latest
Warning

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

Go to latest
Published: May 15, 2018 License: BSD-3-Clause Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbsPolicy

type AbsPolicy struct {
	Name  string
	Funct func(vals ...Hit) interface{}
}

func AbsPolicySumOfInt

func AbsPolicySumOfInt() *AbsPolicy

type Abstract

type Abstract struct {
	// stat key
	Key string `json:"key,omitempty"`
	// stat value
	Val interface{} `json:"val"`
	// the middle value timestamp of the stat object in epoch second
	MidTs int64 `json:"midts"`
	// the length of stat object in second
	Len float64 `json:"len,omitemtpy"`
}

Abstract is the abstract of Hits over a particular period of time An abstract is usually set to the mean, sum or residue of Hits

type AbstractArray

type AbstractArray struct {
	// the abstract array
	Array []Abstract `json:"array"`
	// the policy name to generate such abstract
	Policy string `json:"policy"`
}

func DefaultAbstractArray

func DefaultAbstractArray() *AbstractArray

type Hit

type Hit struct {
	// stat key
	Key string `json:"key,omitempty"`
	// stat value
	Val interface{} `json:"val"`
}

Hit is a single hit of stat record

type StatsManager

type StatsManager struct {

	// channel of hits
	StatsChan map[string]chan Hit
	// accumulative hits
	StatsAcc      map[string]*[]Hit
	StatsPolicies map[string]*AbsPolicy
	// contains filtered or unexported fields
}

func GetStatsInstance

func GetStatsInstance() *StatsManager

func (*StatsManager) Observe

func (sm *StatsManager) Observe(route string)

Specify the custom route to observe

func (*StatsManager) Record

func (sm *StatsManager) Record(t string, v interface{}, k ...string) error

Record a hit

func (*StatsManager) Stats

func (sm *StatsManager) Stats() map[string]*AbstractArray

Return a map of routes - AbstractArray

Jump to

Keyboard shortcuts

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