stats

package
v0.0.0-...-61e9026 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basic

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

Basic is a stats.Recorder and stats.Provider that records and provides stats.Snapshot values. Storage is in-memory and all stats are reset when the agent is restarted.

func NewBasic

func NewBasic() *Basic

func (*Basic) Register

func (s *Basic) Register(id string, handlers []string)

func (*Basic) SendFailed

func (s *Basic) SendFailed(id string, handler string)

func (*Basic) SendSucceeded

func (s *Basic) SendSucceeded(id string, handler string)

func (*Basic) Snapshot

func (s *Basic) Snapshot() Snapshot

type Provider

type Provider interface {
	// Snapshot returns a Snapshot containing current stats.
	Snapshot() Snapshot
}

A Provider provides recorded stats in the form of a Snapshot.

type Recorder

type Recorder interface {
	Register(id string, handlers []string)
	SendSucceeded(id string, handler string)
	SendFailed(id string, handler string)
}

A Recorder records the result of sending a metrics.StampedMetricReport to one or more endpoints.

A Recorder expects the following flow:

  1. The Register method is called prior to performing a send. The method is passed the ID of the StampedMetricReport being sent and a list of the handlers that will perform the operation. Register is called by the first Sender in a pipeline, generally a sender.Dispatcher.
  2. As each handler succeeds or fails in performing its portion of the overall operation, it registers the result using the SendSucceeded and SendFailed methods. The handlers are generally instances of sender.RetryingSender, wrapping endpoints.

The id value should be set to the value of a StampedMetricReport.Id. A handler should generally be set to the name of an endpoint handling part of the send operation.

func NewNoopRecorder

func NewNoopRecorder() Recorder

NewNoopRecorder returns a Recorder that does nothing.

type Snapshot

type Snapshot struct {
	// The last time a send succeeded.
	LastReportSuccess time.Time `json:"lastReportSuccess"`

	// The number of failures since the last success.
	CurrentFailureCount int `json:"currentFailureCount"`

	// The number of failures since the last success.
	TotalFailureCount int `json:"totalFailureCount"`
}

Snapshot encapsulates a point-in-time snapshot of agent send stats.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL