statistics

package
v0.18.18 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 5 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

This section is empty.

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 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 {
	Actions      ActionStatsMap
	RestRequests RequestStatsMap
	Level        StatsLevel
	// contains filtered or unexported fields
}

Collector of statistics

func NewCollector

func NewCollector() *Collector

NewCollector of statistics

func (*Collector) ActionsLen added in v0.5.4

func (collector *Collector) ActionsLen() int

ActionsLen length of action stats map of collector

func (*Collector) CreatedApps added in v0.5.4

func (collector *Collector) CreatedApps() uint64

CreatedApps total apps created count

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) IncCreatedApps added in v0.5.4

func (collector *Collector) IncCreatedApps()

IncCreatedApps increase total created apps counted by one

func (*Collector) IncOpenedApps added in v0.5.4

func (collector *Collector) IncOpenedApps()

IncOpenedApps increase total opened apps counted by one

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) OpenedApps added in v0.5.4

func (collector *Collector) OpenedApps() uint64

OpenedApps total opened apps counted

func (*Collector) RESTRequestLen added in v0.5.4

func (collector *Collector) RESTRequestLen() int

RESTRequestLen length of REST requests stats map of collector

func (*Collector) SetLevel

func (collector *Collector) SetLevel(level StatsLevel) error

SetLevel of statistics collected

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 Errors added in v0.14.0

type Errors struct {
	// contains filtered or unexported fields
}

func (*Errors) Add added in v0.14.0

func (errors *Errors) Add(u uint64) uint64

Add value to counter

func (*Errors) Current added in v0.14.0

func (errors *Errors) Current() uint64

Current value of counter

func (*Errors) Inc added in v0.14.0

func (errors *Errors) Inc() uint64

// Inc increase counter by 1

func (*Errors) Reset added in v0.14.0

func (errors *Errors) Reset()

Reset counter to 0

func (*Errors) String added in v0.14.0

func (errors *Errors) String() string

String implements Stringer interface

type ExecutionCounters added in v0.5.4

type ExecutionCounters struct {
	// Threads - Total started threads
	Threads atomichandlers.AtomicCounter
	// Sessions - Total started sessions
	Sessions atomichandlers.AtomicCounter
	// Users - Total unique users
	Users atomichandlers.AtomicCounter
	// Warnings - Total warnings
	Warnings atomichandlers.AtomicCounter
	// ActionID - Unique global action id
	ActionID atomichandlers.AtomicCounter
	// Requests - Total requests sent
	Requests atomichandlers.AtomicCounter
	// ActiveUsers - Currently active users
	ActiveUsers atomichandlers.AtomicCounter
	// AppCounter -  App counter for round robin access
	AppCounter atomichandlers.AtomicCounter
	// RestRequestID - Added to REST traffic log to connect Request and Response
	RestRequestID atomichandlers.AtomicCounter
	// StatisticsCollector optional collection of statistics
	StatisticsCollector *Collector

	// Errors - Total errors
	Errors Errors
}

ExecutionCounters counts values during a execution

func (*ExecutionCounters) SetMaxErrors added in v0.14.0

func (counters *ExecutionCounters) SetMaxErrors(maxErrors uint64, triggerFunc func(msg string))

SetMaxErrors set a function (e.g. execution cancel) to be triggered each time Inc is called with a value >= maxerrors

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