metrics

package module
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CalculateFunc

type CalculateFunc func(prev *MetricValue, val any, timestamp time.Time) (any, bool)

CalculateFunc defines how to process metric values by the calculator. It passes previously received MetricValue, and the current raw value and timestamp as parameters. Returns true if the calculation is executed successfully.

type Key

type Key struct {
	MetricMetadata any
	MetricLabels   attribute.Distinct
}

func NewKey

func NewKey(metricMetadata any, labels map[string]string) Key

type MapWithExpiry

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

MapWithExpiry act like a map which provides a method to clean up expired entries. MapWithExpiry is not thread safe and locks must be managed by the owner of the Map by the use of Lock() and Unlock()

func NewMapWithExpiry

func NewMapWithExpiry(ttl time.Duration) *MapWithExpiry

NewMapWithExpiry automatically starts a sweeper to enforce the maps TTL. ShutDown() must be called to ensure that these go routines are properly cleaned up ShutDown() must be called.

func (*MapWithExpiry) CleanUp

func (m *MapWithExpiry) CleanUp(now time.Time)

func (*MapWithExpiry) Get

func (m *MapWithExpiry) Get(key Key) (*MetricValue, bool)

func (*MapWithExpiry) Lock

func (m *MapWithExpiry) Lock()

func (*MapWithExpiry) Set

func (m *MapWithExpiry) Set(key Key, value MetricValue)

func (*MapWithExpiry) Shutdown added in v0.83.0

func (m *MapWithExpiry) Shutdown() error

func (*MapWithExpiry) Size

func (m *MapWithExpiry) Size() int

func (*MapWithExpiry) Unlock

func (m *MapWithExpiry) Unlock()

type MetricCalculator

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

MetricCalculator is a calculator used to adjust metric values based on its previous record. Shutdown() must be called to clean up goroutines before program exit.

func NewFloat64DeltaCalculator

func NewFloat64DeltaCalculator() MetricCalculator

func NewMetricCalculator

func NewMetricCalculator(calculateFunc CalculateFunc) MetricCalculator

NewMetricCalculator Creates a metric calculator that enforces a five-minute time to live on cache entries.

func (*MetricCalculator) Calculate

func (rm *MetricCalculator) Calculate(mKey Key, value any, timestamp time.Time) (any, bool)

Calculate accepts a new metric value identified by metric key (consists of metric metadata and labels), https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/eacfde3fcbd46ba60a6db0e9a41977390c4883bd/internal/aws/metrics/metric_calculator.go#L88-L91 and delegates the calculation with value and timestamp back to CalculateFunc for the result. Returns true if the calculation is executed successfully.

func (*MetricCalculator) Shutdown added in v0.83.0

func (rm *MetricCalculator) Shutdown() error

type MetricValue

type MetricValue struct {
	RawValue  any
	Timestamp time.Time
}

Jump to

Keyboard shortcuts

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