latency

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package latency provides a convenient abstraction around timing the startup and bootstrap of a Kubernetes node. latency provides an extensibility mechanism to register custom sources and events, but also ships with a set of default sources and events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Name            string `json:"name"`
	Metric          string `json:"metric"`
	Search          string `json:"search"`
	FirstOccurrence bool   `json:"firstOccurrence"`
	Terminal        bool   `json:"terminal"`
	Src             string `json:"src"`
	// contains filtered or unexported fields
}

Event defines what is being timed from a specific source

type Measurement

type Measurement struct {
	Metadata *Metadata `json:"metadata"`
	Timings  []*Timing `json:"timings"`
}

Measurement is a specific timing produced from a Measurer run

func (*Measurement) Chart

func (m *Measurement) Chart()

Chart generates a markdown chart view of a Measurement

func (*Measurement) EmitCloudWatchMetrics

func (m *Measurement) EmitCloudWatchMetrics(ctx context.Context, cw *cloudwatch.Client, experimentDimension string) error

EmitCloudWatchMetrics posts metric data to CloudWatch based on a Measurement

func (*Measurement) RegisterMetrics

func (m *Measurement) RegisterMetrics(register prometheus.Registerer, experimentDimension string)

RegisterMetrics registers prometheus metrics based on a measurement

type Measurer

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

Measurer holds registered sources and events to use for timing runs

func New

func New() *Measurer

New creates a new instance of a Measurer

func (*Measurer) GetSource

func (m *Measurer) GetSource(name string) (sources.Source, bool)

GetSource looks up a registered source by name

func (*Measurer) Measure

func (m *Measurer) Measure(ctx context.Context) *Measurement

Measure executes a single timing run with the registered sources and events

func (*Measurer) MeasureUntil

func (m *Measurer) MeasureUntil(ctx context.Context, timeout time.Duration, retryDelay time.Duration) *Measurement

MeasureUntil executes timing runs with the registered sources and events until all terminal events have timings or the timeout is reached

func (*Measurer) MustWithDefaultConfig

func (m *Measurer) MustWithDefaultConfig() *Measurer

MustWithDefaultConfig registers the default sources and events to the Measurer and panics if any errors occur

func (*Measurer) RegisterDefaultEvents

func (m *Measurer) RegisterDefaultEvents() (*Measurer, error)

RegisterDefaultEvents registers all default events shipped

func (*Measurer) RegisterDefaultSources

func (m *Measurer) RegisterDefaultSources() *Measurer

RegisterDefaultSources registers the default sources to the Measurer

func (*Measurer) RegisterEvents

func (m *Measurer) RegisterEvents(events ...*Event) (*Measurer, error)

RegisterEvents registers n events to the Measurer. The sources for the events must already be registered.

func (*Measurer) RegisterSources

func (m *Measurer) RegisterSources(srcs ...sources.Source) *Measurer

RegisterSources registers n sources to the Measurer

func (*Measurer) WithIMDS

func (m *Measurer) WithIMDS(imdsClient *imds.Client) *Measurer

WithIMDS is a builder func that adds an EC2 Instance Metadata Service (IMDS) client to a Measurer

type Metadata

type Metadata struct {
	Region           string `json:"region"`
	InstanceType     string `json:"instanceType"`
	InstanceID       string `json:"instanceID"`
	AccountID        string `json:"accountID"`
	Architecture     string `json:"architecture"`
	AvailabilityZone string `json:"availabilityZone"`
	PrivateIP        string `json:"privateIP"`
	AMIID            string `json:"amiID"`
}

Metadata provides data about the node where measurements are executed

type Timing

type Timing struct {
	Event     *Event        `json:"event"`
	Timestamp time.Time     `json:"timestamp"`
	T         time.Duration `json:"seconds"`
	Error     error         `json:"error"`
}

Timing is a specific instance of an Event timing

Jump to

Keyboard shortcuts

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