metrics

package
v1.0.23 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: ISC Imports: 15 Imported by: 0

Documentation

Overview

Package metrics provides general system and process level metrics collection.

Index

Constants

View Source
const InitialResettingTimerSliceCap = 10

Initial slice capacity for the values stored in a ResettingTimer

View Source
const MetricsEnabledFlag = "metrics"

MetricsEnabledFlag is the CLI flag name to use to enable metrics collections.

Variables

View Source
var Enabled = false

Enabled is the flag specifying if metrics are enable or not.

Functions

func CollectProcessMetrics

func CollectProcessMetrics(refresh time.Duration)

CollectProcessMetrics periodically collects various metrics about the running process.

func NewCounter

func NewCounter(name string) metrics.Counter

NewCounter create a new metrics Counter, either a real one of a NOP stub depending on the metrics flag.

func NewMeter

func NewMeter(name string) metrics.Meter

NewMeter create a new metrics Meter, either a real one of a NOP stub depending on the metrics flag.

func NewRegisteredCounter

func NewRegisteredCounter(name string, r metrics.Registry) metrics.Counter

func NewRegisteredMeter

func NewRegisteredMeter(name string, r metrics.Registry) metrics.Meter

func NewTimer

func NewTimer(name string) metrics.Timer

NewTimer create a new metrics Timer, either a real one of a NOP stub depending on the metrics flag.

func ReadDiskStats

func ReadDiskStats(stats *DiskStats) error

ReadDiskStats retrieves the disk IO stats belonging to the current process.

Types

type DiskStats

type DiskStats struct {
	ReadCount  int64 // Number of read operations executed
	ReadBytes  int64 // Total number of bytes read
	WriteCount int64 // Number of write operations executed
	WriteBytes int64 // Total number of byte written
}

DiskStats is the per process disk io stats.

type Int64Slice

type Int64Slice []int64

Int64Slice attaches the methods of sort.Interface to []int64, sorting in increasing order.

func (Int64Slice) Len

func (s Int64Slice) Len() int

func (Int64Slice) Less

func (s Int64Slice) Less(i, j int) bool

func (Int64Slice) Swap

func (s Int64Slice) Swap(i, j int)

type NilResettingTimer

type NilResettingTimer struct {
}

NilResettingTimer is a no-op ResettingTimer.

func (NilResettingTimer) Mean

func (NilResettingTimer) Mean() float64

Mean panics.

func (NilResettingTimer) Percentiles

func (NilResettingTimer) Percentiles([]float64) []int64

Percentiles panics.

func (NilResettingTimer) Snapshot

func (NilResettingTimer) Snapshot() ResettingTimer

Snapshot is a no-op.

func (NilResettingTimer) Time

func (NilResettingTimer) Time(func())

Time is a no-op.

func (NilResettingTimer) Update

Update is a no-op.

func (NilResettingTimer) UpdateSince

func (NilResettingTimer) UpdateSince(time.Time)

UpdateSince is a no-op.

func (NilResettingTimer) Values

func (NilResettingTimer) Values() []int64

Values is a no-op.

type ResettingTimer

type ResettingTimer interface {
	Values() []int64
	Snapshot() ResettingTimer
	Percentiles([]float64) []int64
	Mean() float64
	Time(func())
	Update(time.Duration)
	UpdateSince(time.Time)
}

ResettingTimer is used for storing aggregated values for timers, which are reset on every flush interval.

func GetOrRegisterResettingTimer

func GetOrRegisterResettingTimer(name string, r metrics.Registry) ResettingTimer

GetOrRegisterResettingTimer returns an existing ResettingTimer or constructs and registers a new StandardResettingTimer.

func NewRegisteredResettingTimer

func NewRegisteredResettingTimer(name string, r metrics.Registry) ResettingTimer

NewRegisteredResettingTimer constructs and registers a new StandardResettingTimer.

func NewResettingTimer

func NewResettingTimer() ResettingTimer

NewResettingTimer constructs a new StandardResettingTimer

type ResettingTimerSnapshot

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

ResettingTimerSnapshot is a point-in-time copy of another ResettingTimer.

func (*ResettingTimerSnapshot) Mean

func (t *ResettingTimerSnapshot) Mean() float64

Mean returns the mean of the snapshotted values

func (*ResettingTimerSnapshot) Percentiles

func (t *ResettingTimerSnapshot) Percentiles(percentiles []float64) []int64

Percentiles returns the boundaries for the input percentiles.

func (*ResettingTimerSnapshot) Snapshot

func (t *ResettingTimerSnapshot) Snapshot() ResettingTimer

Snapshot returns the snapshot.

func (*ResettingTimerSnapshot) Time

func (*ResettingTimerSnapshot) Time(func())

Time panics.

func (*ResettingTimerSnapshot) Update

Update panics.

func (*ResettingTimerSnapshot) UpdateSince

func (*ResettingTimerSnapshot) UpdateSince(time.Time)

UpdateSince panics.

func (*ResettingTimerSnapshot) Values

func (t *ResettingTimerSnapshot) Values() []int64

Values returns all values from snapshot.

type StandardResettingTimer

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

StandardResettingTimer is the standard implementation of a ResettingTimer. and Meter.

func (*StandardResettingTimer) Mean

func (t *StandardResettingTimer) Mean() float64

Mean panics.

func (*StandardResettingTimer) Percentiles

func (t *StandardResettingTimer) Percentiles([]float64) []int64

Percentiles panics.

func (*StandardResettingTimer) Snapshot

func (t *StandardResettingTimer) Snapshot() ResettingTimer

Snapshot resets the timer and returns a read-only copy of its contents.

func (*StandardResettingTimer) Time

func (t *StandardResettingTimer) Time(f func())

Record the duration of the execution of the given function.

func (*StandardResettingTimer) Update

func (t *StandardResettingTimer) Update(d time.Duration)

Record the duration of an event.

func (*StandardResettingTimer) UpdateSince

func (t *StandardResettingTimer) UpdateSince(ts time.Time)

Record the duration of an event that started at a time and ends now.

func (*StandardResettingTimer) Values

func (t *StandardResettingTimer) Values() []int64

Values returns a slice with all measurements.

Jump to

Keyboard shortcuts

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