Documentation ¶
Index ¶
- Variables
- func CreatedApps() uint64
- func DestroyGlobalCollector()
- func ForEachAction(f func(stats *ActionStats))
- func ForEachRequest(f func(stats *RequestStats))
- func GlobalActionsLen() int
- func GlobalRESTRequestLen() int
- func IncCreatedApps()
- func IncOpenedApps()
- func OpenedApps() uint64
- func SetGlobalLevel(level StatsLevel)
- type ActionStats
- type ActionStatsMap
- type Collector
- func (collector *Collector) ForEachAction(f func(stats *ActionStats))
- func (collector *Collector) ForEachRequest(f func(stats *RequestStats))
- func (collector *Collector) GetOrAddActionStats(name, label, appGUID string) *ActionStats
- func (collector *Collector) GetOrAddRequestStats(method, path string) *RequestStats
- func (collector *Collector) IsFull() bool
- func (collector *Collector) IsOn() bool
- func (collector *Collector) SetLevel(level StatsLevel) error
- type Counters
- type ErrWarn
- type RequestStats
- type RequestStatsMap
- type SampleCollector
- type StatsLevel
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultHotBuffer, default size of hot buffer DefaultHotBuffer = 300 // todo investigate good value // DefaultPurgeExpiry, default time until hot buffer will be purged DefaultPurgeExpiry = time.Second * 5 )
Functions ¶
func CreatedApps ¶
func CreatedApps() uint64
CreatedApps total apps created count in global stats collector
func DestroyGlobalCollector ¶
func DestroyGlobalCollector()
DestroyGlobalCollector set global connector to nil, mostly to be used in tests.
func ForEachAction ¶
func ForEachAction(f func(stats *ActionStats))
ForEachAction locks map and execute function for each ActionStats entry of global collector
func ForEachRequest ¶
func ForEachRequest(f func(stats *RequestStats))
ForEachRequest read lock map and execute function for each RequestStats entry of global collector
func GlobalActionsLen ¶
func GlobalActionsLen() int
GlobalActionsLen length of action stats map of global collector
func GlobalRESTRequestLen ¶
func GlobalRESTRequestLen() int
GlobalRESTRequestLen length of REST requests stats map of global collector
func IncCreatedApps ¶
func IncCreatedApps()
IncCreatedApps increase total created apps counted by one in global stats collector
func IncOpenedApps ¶
func IncOpenedApps()
IncOpenedApps increase total opened apps counted by one in global stats collector
func OpenedApps ¶
func OpenedApps() uint64
OpenedApps total opened apps counted in global stats collector
func SetGlobalLevel ¶
func SetGlobalLevel(level StatsLevel)
SetGlobalLevel of statistics collected of global collector
Types ¶
type ActionStats ¶
type ActionStats struct { // RespAvg average response time for successful actions RespAvg *SampleCollector // Requests total count of requests sent within action Requests atomichandlers.AtomicCounter // ErrCount total amount of errors within action ErrCount atomichandlers.AtomicCounter // WarnCount total amount of warnings within action WarnCount atomichandlers.AtomicCounter // Sent total amount of sent bytes Sent atomichandlers.AtomicCounter // Received total amount of received bytes Received atomichandlers.AtomicCounter // Failed total amount of failed actions, can be compared with RespAvg.count for success rate Failed atomichandlers.AtomicCounter // contains filtered or unexported fields }
ActionStats statistics collector for an Action
func GetOrAddGlobalActionStats ¶
func GetOrAddGlobalActionStats(name, label, appGUID string) *ActionStats
GetOrAddActionStats from action map of global collector, returns nil if statistics is turned off
func NewActionStats ¶
func NewActionStats(name, label, appGUID string) *ActionStats
NewActionStats creates a new action statistics collector
func (*ActionStats) AppGUID ¶
func (action *ActionStats) AppGUID() string
AppGUID in which action was performed
type ActionStatsMap ¶
type ActionStatsMap map[string]*ActionStats
type Collector ¶
type Collector struct { Counters Actions ActionStatsMap RestRequests RequestStatsMap Level StatsLevel // contains filtered or unexported fields }
Collector of statistics
func (*Collector) ForEachAction ¶
func (collector *Collector) ForEachAction(f func(stats *ActionStats))
ForEachAction read lock map and execute function for each ActionStats entry
func (*Collector) ForEachRequest ¶
func (collector *Collector) ForEachRequest(f func(stats *RequestStats))
ForEachRequest read lock map and execute function for each RequestStats entry
func (*Collector) GetOrAddActionStats ¶
func (collector *Collector) GetOrAddActionStats(name, label, appGUID string) *ActionStats
GetOrAddActionStats from action map, returns nil if statistics is turned off
func (*Collector) GetOrAddRequestStats ¶
func (collector *Collector) GetOrAddRequestStats(method, path string) *RequestStats
GetOrAddRequestStats from REST request map, returns nil if StatsLevel is lower than "full"
func (*Collector) SetLevel ¶
func (collector *Collector) SetLevel(level StatsLevel) error
SetLevel of statistics collected
type Counters ¶
type Counters struct {
// contains filtered or unexported fields
}
Counters collecting statistics
func (*Counters) CreatedApps ¶
CreatedApps total apps created count
func (*Counters) IncCreatedApps ¶
func (counter *Counters) IncCreatedApps()
IncCreatedApps increase total created apps counted by one
func (*Counters) IncOpenedApps ¶
func (counter *Counters) IncOpenedApps()
IncOpenedApps increase total opened apps counted by one
func (*Counters) OpenedApps ¶
OpenedApps total opened apps counted
type ErrWarn ¶
type ErrWarn struct {
// contains filtered or unexported fields
}
ErrWarn keeps track of errors and warnings within action + total
func (*ErrWarn) TotWarnings ¶
TotWarnings report total warnings count
type RequestStats ¶
type RequestStats struct { RespAvg *SampleCollector Sent atomichandlers.AtomicCounter Received atomichandlers.AtomicCounter // contains filtered or unexported fields }
RequestStats statistics collector for a REST request
func GetOrAddGlobalRequestStats ¶
func GetOrAddGlobalRequestStats(method, path string) *RequestStats
GetOrAddGlobalRequestStats from REST request map of global collector, returns nil if StatsLevel is lower than "full"
func NewRequestStats ¶
func NewRequestStats(method, path string) *RequestStats
NewRequestStats creates a new REST request statistics collector
type RequestStatsMap ¶
type RequestStatsMap map[string]*RequestStats
type SampleCollector ¶
type SampleCollector struct {
// contains filtered or unexported fields
}
func NewSampleCollector ¶
func NewSampleCollector() *SampleCollector
NewSampleCollector for collecting running average
func NewSampleCollectorBuf ¶
func NewSampleCollectorBuf(buf int) *SampleCollector
NewSampleCollector for collecting running average with custom hot buffer size
func (*SampleCollector) AddSample ¶
func (collector *SampleCollector) AddSample(sample uint64)
AddSample add new sample
func (*SampleCollector) Average ¶
func (collector *SampleCollector) Average() (float64, float64)
Average empties hot buffer and calculates current running average, returns average, total samples.
type StatsLevel ¶
type StatsLevel int
const ( StatsLevelNone StatsLevel = iota StatsLevelOn StatsLevelFull )
StatsLevel enum