Documentation ¶
Overview ¶
The Tideland Go Library monitoring package supports three kinds of system monitoring. They are helpful to understand what's happening inside a system during runtime. So execution times can be measured and analyzed, stay-set variables integrated and dynamic control value retrieval provided. The backend is exchangeable. So the StandardBackend workes like described above, the NullBackend does nothing, and own implementations can integrate external systems. Additionally filters can be added to reduce the monitoring to the points of interest.
Index ¶
- Constants
- func DecrVariable(id string)
- func DynamicStatusValuesDo(f func(DynamicStatusValue)) error
- func DynamicStatusValuesPrintAll() error
- func DynamicStatusValuesWrite(w io.Writer, ff func(DynamicStatusValue) bool) error
- func IncrVariable(id string)
- func IsDynamicStatusNotExistsError(err error) bool
- func IsMeasuringPointNotExistsError(err error) bool
- func IsMonitoringCannotBeRecoveredError(err error) bool
- func IsMonitoringPanickedError(err error) bool
- func IsStaySetVariableNotExistsError(err error) bool
- func Measure(id string, f func()) time.Duration
- func MeasuringPointsDo(f func(MeasuringPoint)) error
- func MeasuringPointsPrintAll() error
- func MeasuringPointsWrite(w io.Writer, ff func(MeasuringPoint) bool) error
- func PackageVersion() version.Version
- func ReadStatus(id string) (string, error)
- func Register(id string, rf DynamicStatusRetriever)
- func Reset() error
- func SetBackend(mb Backend)
- func SetVariable(id string, v int64)
- func StaySetVariablesDo(f func(StaySetVariable)) error
- func StaySetVariablesPrintAll() error
- func StaySetVariablesWrite(w io.Writer, ff func(StaySetVariable) bool) error
- type Backend
- type DynamicStatusRetriever
- type DynamicStatusValue
- type DynamicStatusValues
- type IDFilter
- type Measuring
- type MeasuringPoint
- type MeasuringPoints
- type StaySetVariable
- type StaySetVariables
Constants ¶
const ( ErrMonitoringPanicked = iota + 1 ErrMonitoringCannotBeRecovered ErrMeasuringPointNotExists ErrStaySetVariableNotExists ErrDynamicStatusNotExists )
Variables ¶
This section is empty.
Functions ¶
func DynamicStatusValuesDo ¶
func DynamicStatusValuesDo(f func(DynamicStatusValue)) error
DynamicStatusValuesDo performs the function f for all status values.
func DynamicStatusValuesPrintAll ¶
func DynamicStatusValuesPrintAll() error
DynamicStatusValuesPrintAll prints all status values to STDOUT.
func DynamicStatusValuesWrite ¶
func DynamicStatusValuesWrite(w io.Writer, ff func(DynamicStatusValue) bool) error
DynamicStatusValuesWrite prints the status values for which the passed function returns true to the passed writer.
func IsDynamicStatusNotExistsError ¶
IsDynamicStatusNotExistsError returns true, if the error signals that a wanted dynamic status cannot be retrieved because it doesn't exists.
func IsMeasuringPointNotExistsError ¶
IsMeasuringPointNotExistsError returns true, if the error signals that a wanted measuring point cannot be retrieved because it doesn't exists.
func IsMonitoringCannotBeRecoveredError ¶
IsMonitoringCannotBeRecoveredError returns true, if the error signals that the monitoring backend has panicked to often and cannot be recovered.
func IsMonitoringPanickedError ¶
IsMonitoringPanickedError returns true, if the error signals that the monitoring backend panicked.
func IsStaySetVariableNotExistsError ¶
IsStaySetVariableNotExistsError returns true, if the error signals that a wanted stay-set variable cannot be retrieved because it doesn't exists.
func MeasuringPointsDo ¶
func MeasuringPointsDo(f func(MeasuringPoint)) error
MeasuringPointsDo performs the function f for all measuring points.
func MeasuringPointsPrintAll ¶
func MeasuringPointsPrintAll() error
MeasuringPointsPrintAll prints all measuring points to STDOUT.
func MeasuringPointsWrite ¶
func MeasuringPointsWrite(w io.Writer, ff func(MeasuringPoint) bool) error
MeasuringPointsWrite prints the measuring points for which the passed function returns true to the passed writer.
func PackageVersion ¶
PackageVersion returns the version of the version package.
func ReadStatus ¶
ReadStatus returns the dynamic status for an id.
func Register ¶
func Register(id string, rf DynamicStatusRetriever)
Register registers a new dynamic status retriever function.
func SetVariable ¶
SetVariable sets a value of a stay-set variable.
func StaySetVariablesDo ¶
func StaySetVariablesDo(f func(StaySetVariable)) error
StaySetVariablesDo performs the function f for all variables.
func StaySetVariablesPrintAll ¶
func StaySetVariablesPrintAll() error
StaySetVariablesPrintAll prints all stay-set variables to STDOUT.
func StaySetVariablesWrite ¶
func StaySetVariablesWrite(w io.Writer, ff func(StaySetVariable) bool) error
StaySetVariablesWrite prints the stay-set variables for which the passed function returns true to the passed writer.
Types ¶
type Backend ¶
type Backend interface { // BeginMeasuring starts a new measuring with a given id. BeginMeasuring(id string) Measuring // ReadMeasuringPoint returns the measuring point for an id. ReadMeasuringPoint(id string) (MeasuringPoint, error) // MeasuringPointsDo performs the function f for // all measuring points. MeasuringPointsDo(f func(MeasuringPoint)) error // SetVariable sets a value of a stay-set variable. SetVariable(id string, v int64) // IncrVariable increases a variable. IncrVariable(id string) // DecrVariable decreases a variable. DecrVariable(id string) // ReadVariable returns the stay-set variable for an id. ReadVariable(id string) (StaySetVariable, error) // StaySetVariablesDo performs the function f for all // variables. StaySetVariablesDo(f func(StaySetVariable)) error // Register registers a new dynamic status retriever function. Register(id string, rf DynamicStatusRetriever) // ReadStatus returns the dynamic status for an id. ReadStatus(id string) (string, error) // DynamicStatusValuesDo performs the function f for all // status values. DynamicStatusValuesDo(f func(DynamicStatusValue)) error // SetMeasuringFilter sets the new filter for measurings // and returns the current one. SetMeasuringsFilter(f IDFilter) IDFilter // SetMeasuringFilter sets the new filter for variables // and returns the current one. SetVariablesFilter(f IDFilter) IDFilter // SetRetrieversFilter sets the new filter for status retrievers // and returns the current one. SetRetrieversFilter(f IDFilter) IDFilter // Reset clears all monitored values. Reset() error // Stop tells the backend that a new one has been set. Stop() }
Backend defines the interface for a type managing all the information provided or needed by the public functions of the monitoring package.
func NewNullBackend ¶
func NewNullBackend() Backend
NewNullBackend starts the null monitoring backend doing nothing.
func NewStandardBackend ¶
func NewStandardBackend() Backend
NewStandardBackend starts the standard monitoring backend.
type DynamicStatusRetriever ¶
DynamicStatusRetriever is called by the server and returns a current status as string.
type DynamicStatusValue ¶
type DynamicStatusValue interface { fmt.Stringer // ID returns the identifier of the status value. ID() string // Value returns the retrieved value as string. Value() string }
DynamicStatusValue contains one retrieved value.
type DynamicStatusValues ¶
type DynamicStatusValues []DynamicStatusValue
DynamicStatusValues is a set of dynamic status values.
func (DynamicStatusValues) Len ¶
func (d DynamicStatusValues) Len() int
func (DynamicStatusValues) Less ¶
func (d DynamicStatusValues) Less(i, j int) bool
func (DynamicStatusValues) Swap ¶
func (d DynamicStatusValues) Swap(i, j int)
type IDFilter ¶
IDFilter allows to add filter for execution time measurings, stay-set values, and dynamic status retriever. If set only monitorings with the filter returning true will be done.
func SetMeasuringsFilter ¶
SetMeasuringFilter sets the new filter for measurings and returns the current one.
func SetRetrieversFilter ¶
SetRetrieversFilter sets the new filter for status retrievers and returns the current one.
func SetVariablesFilter ¶
SetMeasuringFilter sets the new filter for variables and returns the current one.
type Measuring ¶
type Measuring interface { // EndMeasuring ends the measuring and passes its // data to the backend. EndMeasuring() time.Duration }
Measuring defines one execution time measuring containg the ID and the starting time of the measuring and able to pass this data after the end of the measuring to its backend.
func BeginMeasuring ¶
BeginMeasuring starts a new measuring with a given id. All measurings with the same id will be aggregated.
type MeasuringPoint ¶
type MeasuringPoint interface { fmt.Stringer // ID returns the identifier of the measuring point. ID() string // Count returns how often this point has been measured. Count() int64 // MinDuration returns the shortest execution time. MinDuration() time.Duration // MaxDuration returns the longest execution time. MaxDuration() time.Duration // AvgDuration returns the average execution time. AvgDuration() time.Duration }
MeasuringPoint defines the collected information for one execution time measuring point.
func ReadMeasuringPoint ¶
func ReadMeasuringPoint(id string) (MeasuringPoint, error)
ReadMeasuringPoint returns the measuring point for an id.
type MeasuringPoints ¶
type MeasuringPoints []MeasuringPoint
MeasuringPoints is a set of measuring points.
func (MeasuringPoints) Len ¶
func (m MeasuringPoints) Len() int
func (MeasuringPoints) Less ¶
func (m MeasuringPoints) Less(i, j int) bool
func (MeasuringPoints) Swap ¶
func (m MeasuringPoints) Swap(i, j int)
type StaySetVariable ¶
type StaySetVariable interface { fmt.Stringer // ID returns the identifier of the stay-set variable. ID() string // Count returns how often the value has been changed. Count() int64 // ActValue returns the current value of the variable. ActValue() int64 // MinValue returns the minimum value of the variable. MinValue() int64 // MaxValue returns the maximum value of the variable. MaxValue() int64 // MinValue returns the average value of the variable. AvgValue() int64 }
StaySetVariable contains the cumulated values for one stay-set variable.
func ReadVariable ¶
func ReadVariable(id string) (StaySetVariable, error)
ReadVariable returns the stay-set variable for an id.
type StaySetVariables ¶
type StaySetVariables []StaySetVariable
StaySetVariables is a set of stay-set variables.
func (StaySetVariables) Len ¶
func (s StaySetVariables) Len() int
func (StaySetVariables) Less ¶
func (s StaySetVariables) Less(i, j int) bool
func (StaySetVariables) Swap ¶
func (s StaySetVariables) Swap(i, j int)