Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbsPolicy ¶
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
Click to show internal directories.
Click to hide internal directories.