Documentation
¶
Overview ¶
Package utilizationtracker provides a utility to track the utilization of a component.
Package utilizationtracker provides a utility to track the utilization of a component.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UtilizationTracker ¶
type UtilizationTracker struct {
Output chan Value
// contains filtered or unexported fields
}
UtilizationTracker tracks the utilization of a component.
func NewUtilizationTracker ¶
func NewUtilizationTracker( interval time.Duration, alpha float64, ) *UtilizationTracker
NewUtilizationTracker instantiates and configures a utilization tracker that calculates the values and publishes them to expvars
func NewUtilizationTrackerWithClock ¶ added in v0.86.0
func NewUtilizationTrackerWithClock(interval time.Duration, clk clock.Clock, alpha float64) *UtilizationTracker
NewUtilizationTrackerWithClock instantiates a tracker driven by the given clock, so that callers (tests, or callers that need to coordinate their own tick timing deterministically) can control the passage of time.
func (*UtilizationTracker) Finished ¶
func (ut *UtilizationTracker) Finished()
Finished should be invoked when a compnent's work is complete so that we can calculate the utilization of the compoennt.
Produces one value on the Output channel.
func (*UtilizationTracker) Started ¶
func (ut *UtilizationTracker) Started(excluded bool)
Started should be invoked when a compnent's work is about to being so that we can track the start time and the utilization. Pass excluded=true when this unit of work should be flagged as excluded (see Value.Excluded) on every reading produced until the matching Finished call.
Produces one value on the Output channel.
func (*UtilizationTracker) Stop ¶
func (ut *UtilizationTracker) Stop()
Stop should be invoked when a component is about to exit so that we can clean up the instances resources.
func (*UtilizationTracker) Tick ¶
func (ut *UtilizationTracker) Tick()
Tick updates to the utilization during intervals where no component were started or stopped.
Produces one value on the Output channel.
type Value ¶ added in v0.86.0
type Value struct {
// Utilization is the utilization fraction as of this reading.
Utilization float64
// Excluded is true when the work in progress at the time of this reading
// was marked as excluded via Started. Callers that aggregate utilization
// across multiple components can use this to skip readings that are not
// representative of normal load, e.g. a unit of work expected to occupy
// the component indefinitely.
Excluded bool
}
Value is a utilization reading produced on a tracker's Output channel.