metrics

package
v0.13.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package metrics provides unified way of emitting metrics inside Kopia.

Index

Constants

This section is empty.

Variables

View Source
var CPULatencyThresholds = &Thresholds[time.Duration]{
	[]time.Duration{
		10 * time.Microsecond,
		25 * time.Microsecond,
		50 * time.Microsecond,

		100 * time.Microsecond,
		250 * time.Microsecond,
		500 * time.Microsecond,

		1000 * time.Microsecond,
		2500 * time.Microsecond,
		5000 * time.Microsecond,

		10 * time.Millisecond,
		25 * time.Millisecond,
		50 * time.Millisecond,

		100 * time.Millisecond,
		250 * time.Millisecond,
		500 * time.Millisecond,

		1000 * time.Millisecond,
		2500 * time.Millisecond,
		5000 * time.Millisecond,
	},
	1,
	"_ns",
}

CPULatencyThresholds is a set of thresholds that can represent CPU latencies from 10us to 5s.

View Source
var IOLatencyThresholds = &Thresholds[time.Duration]{
	[]time.Duration{
		500 * time.Microsecond,

		1000 * time.Microsecond,
		2500 * time.Microsecond,
		5000 * time.Microsecond,

		10 * time.Millisecond,
		25 * time.Millisecond,
		50 * time.Millisecond,

		100 * time.Millisecond,
		250 * time.Millisecond,
		500 * time.Millisecond,

		1000 * time.Millisecond,
		2500 * time.Millisecond,
		5000 * time.Millisecond,

		10 * time.Second,
		25 * time.Second,
		50 * time.Second,
	},
	1e6,
	"_ms",
}

IOLatencyThresholds is a set of thresholds that can represent IO latencies from 500us to 50s.

View Source
var ISOBytesThresholds = &Thresholds[int64]{
	[]int64{
		100,
		250,
		500,
		1_000,
		2_500,
		5_000,
		10_000,
		25_000,
		50_000,
		100_000,
		250_000,
		500_000,
		1_000_000,
		2_500_000,
		5_000_000,
		10_000_000,
		25_000_000,
		50_000_000,
		100_000_000,
		250_000_000,
		500_000_000,
	},
	1,
	"",
}

ISOBytesThresholds is a set of thresholds for sizes.

Functions

This section is empty.

Types

type Counter

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

Counter represents a monotonically increasing int64 counter value.

func (*Counter) Add

func (c *Counter) Add(v int64)

Add adds a value to a counter.

func (*Counter) Snapshot

func (c *Counter) Snapshot(reset bool) int64

Snapshot captures the momentary state of a counter.

type Distribution

type Distribution[T constraints.Integer | constraints.Float] struct {
	// contains filtered or unexported fields
}

Distribution measures distribution/summary of values.

func (*Distribution[T]) Observe

func (d *Distribution[T]) Observe(value T)

Observe adds the provided observation value to the summary.

func (*Distribution[T]) Snapshot

func (d *Distribution[T]) Snapshot(reset bool) *DistributionState[T]

Snapshot returns a snapshot of the distribution state.

type DistributionState

type DistributionState[T constraints.Float | constraints.Integer] struct {
	Min              T       `json:"min"`
	Max              T       `json:"max"`
	Sum              T       `json:"sum"`
	Count            int64   `json:"count"`
	BucketCounters   []int64 `json:"buckets"`
	BucketThresholds []T     `json:"-"`
}

DistributionState captures momentary state of a Distribution.

func (*DistributionState[T]) Mean

func (s *DistributionState[T]) Mean() T

Mean returns arithmetic mean value captured in the distribution.

type Registry

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

Registry groups together all metrics stored in the repository and provides ways of accessing them.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns new metrics registry.

func (*Registry) Close

func (r *Registry) Close(ctx context.Context) error

Close closes the metrics registry.

func (*Registry) CounterInt64

func (r *Registry) CounterInt64(name, help string, labels map[string]string) *Counter

CounterInt64 gets a persistent int64 counter with the provided name.

func (*Registry) DurationDistribution

func (r *Registry) DurationDistribution(name, help string, thresholds *Thresholds[time.Duration], labels map[string]string) *Distribution[time.Duration]

DurationDistribution gets a persistent duration distribution with the provided name.

func (*Registry) Log

func (r *Registry) Log(ctx context.Context)

Log logs all metrics in the registry.

func (*Registry) SizeDistribution

func (r *Registry) SizeDistribution(name, help string, thresholds *Thresholds[int64], labels map[string]string) *Distribution[int64]

SizeDistribution gets a persistent size distribution with the provided name.

func (*Registry) Snapshot

func (r *Registry) Snapshot(reset bool) Snapshot

Snapshot captures the snapshot of all metrics.

func (*Registry) Throughput

func (r *Registry) Throughput(name, help string, labels map[string]string) *Throughput

Throughput gets a persistent counter with the provided name.

type Snapshot

type Snapshot struct {
	Counters              map[string]int64                             `json:"counters"`
	DurationDistributions map[string]*DistributionState[time.Duration] `json:"durationDistributions"`
	SizeDistributions     map[string]*DistributionState[int64]         `json:"sizeDistributions"`
}

Snapshot captures the state of all metrics.

func AggregateSnapshots

func AggregateSnapshots(snapshots []Snapshot) Snapshot

AggregateSnapshots computes aggregate of the provided snapshots.

type Thresholds

type Thresholds[T constraints.Float | constraints.Integer] struct {
	// contains filtered or unexported fields
}

Thresholds encapsulates a set of bucket thresholds used in Summary[T].

type Throughput

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

Throughput measures throughput by keeping track of total value and total duration.

func (*Throughput) Observe

func (c *Throughput) Observe(size int64, dt time.Duration)

Observe increases duration and total value counters based on the amount of time to process particular amount of data.

Jump to

Keyboard shortcuts

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