Documentation ¶
Overview ¶
Package metrics provides common functionality for working with metrics, particulary useful for monitoring components. It includes types to store, check and filter metrics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AlertChannelCap = 256
AlertChannelCap specifies how much buffer the alerts channel has.
var DefaultWindowCap = 25
DefaultWindowCap sets the amount of metrics to store per peer.
var ErrAlertChannelFull = errors.New("alert channel is full")
ErrAlertChannelFull is returned if the alert channel is full.
var ErrNoMetrics = errors.New("no metrics have been added to this window")
ErrNoMetrics is returned when there are no metrics in a Window.
Functions ¶
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker provides utilities to find expired metrics for a given peerset and send alerts if it proceeds to do so.
func NewChecker ¶
NewChecker creates a Checker using the given MetricsStore.
func (*Checker) CheckPeers ¶
CheckPeers will trigger alerts for expired metrics belonging to the given peerset.
func (*Checker) Watch ¶
func (mc *Checker) Watch(ctx context.Context, peersF func(context.Context) ([]peer.ID, error), interval time.Duration)
Watch will trigger regular CheckPeers on the given interval. It will call peersF to obtain a peerset. It can be stopped by cancelling the context. Usually you want to launch this in a goroutine.
type PeerMetrics ¶
PeerMetrics maps a peer IDs to a metrics window.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store can be used to store and access metrics.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window implements a circular queue to store metrics.
func (*Window) Add ¶
Add adds a new metric to the window. If the window capacity has been reached, the oldest metric (by the time it was added), will be discarded.