statistics

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func (*ActionStats) Label

func (action *ActionStats) Label() string

Label action label

func (*ActionStats) Name

func (action *ActionStats) Name() string

Name of action

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 NewCollector

func NewCollector() *Collector

NewCollector 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) IsFull

func (collector *Collector) IsFull() bool

IsFull full statistics collection is turned on

func (*Collector) IsOn

func (collector *Collector) IsOn() bool

IsOn statistics collection is turned on

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

func (counter *Counters) CreatedApps() uint64

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

func (counter *Counters) OpenedApps() uint64

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

func (ew *ErrWarn) Errors() uint64

Errors report error count

func (*ErrWarn) IncErr

func (ew *ErrWarn) IncErr()

IncErr Add 1 to errors counter

func (*ErrWarn) IncWarn

func (ew *ErrWarn) IncWarn()

IncWarn Add 1 to warnings counter

func (*ErrWarn) Reset

func (ew *ErrWarn) Reset()

Reset reset error and warnings counters

func (*ErrWarn) TotErrors

func (ew *ErrWarn) TotErrors() uint64

TotErrors report total error count

func (*ErrWarn) TotWarnings

func (ew *ErrWarn) TotWarnings() uint64

TotWarnings report total warnings count

func (*ErrWarn) Warnings

func (ew *ErrWarn) Warnings() uint64

Warnings report warning 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

func (*RequestStats) Method

func (request *RequestStats) Method() string

Method of request

func (*RequestStats) Path

func (request *RequestStats) Path() string

Path of request

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

Jump to

Keyboard shortcuts

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