Documentation
¶
Overview ¶
Package monitor helps monitoring of Go applications. The stop watch part allows to measure the execution time and retrieve how often it is called, minimum, maximum, and average durations. Another one is the stay-set indicator allowing to increase and decrease values and retrieve count, maximum, minimum, and current value. This can help to control and manage limiters or pools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IndicatorValue ¶
IndicatorValue manages the value range for one indicator.
func (*IndicatorValue) String ¶
func (iv *IndicatorValue) String() string
String implements fmt.Stringer.
type IndicatorValues ¶
type IndicatorValues []IndicatorValue
IndicatorValues is a set of stay-set values.
func (IndicatorValues) Len ¶
func (ivs IndicatorValues) Len() int
func (IndicatorValues) Less ¶
func (ivs IndicatorValues) Less(i, j int) bool
func (IndicatorValues) Swap ¶
func (ivs IndicatorValues) Swap(i, j int)
type Measuring ¶
type Measuring struct {
// contains filtered or unexported fields
}
Measuring defines one execution time measuring containing the ID and the starting time of the measuring and able to pass this data after the end of the measuring to the measurer.
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor combines StopWatch and StaySetIndicator.
func FromContext ¶
FromContext retrieves a logger from a context.
func (*Monitor) StaySetIndicator ¶
func (m *Monitor) StaySetIndicator() *StaySetIndicator
StaySetIndicator returns a stay-set indicator instance.
type StaySetIndicator ¶
type StaySetIndicator struct {
// contains filtered or unexported fields
}
StaySetIndicator allows to increase and decrease stay-set values.
func (*StaySetIndicator) Decrease ¶
func (i *StaySetIndicator) Decrease(id string)
Decrease decreases a stay-set staySetIndicator.
func (*StaySetIndicator) Do ¶
func (i *StaySetIndicator) Do(f func(IndicatorValue) error) error
Do performs the function f for all values.
func (*StaySetIndicator) Increase ¶
func (i *StaySetIndicator) Increase(id string)
Increase increases a stay-set staySetIndicator.
func (*StaySetIndicator) Read ¶
func (i *StaySetIndicator) Read(id string) (IndicatorValue, error)
Read returns a stay-set staySetIndicator.
type StopWatch ¶
type StopWatch struct {
// contains filtered or unexported fields
}
StopWatch allows to measure the execution time of code fragments.
func (*StopWatch) Do ¶
func (s *StopWatch) Do(f func(WatchValue) error) error
Do performs the function f for all measuring points.
type WatchValue ¶
type WatchValue struct {
ID string
Count int
Total time.Duration
Min time.Duration
Max time.Duration
Avg time.Duration
}
WatchValue manages the value range for one watch.
type WatchValues ¶
type WatchValues []WatchValue
WatchValues is a set of values.
func (WatchValues) Len ¶
func (wvs WatchValues) Len() int
func (WatchValues) Less ¶
func (wvs WatchValues) Less(i, j int) bool
func (WatchValues) Swap ¶
func (wvs WatchValues) Swap(i, j int)