metrics

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenericMetric

type GenericMetric[T NumericOrDuration] struct {
	Value T
}

GenericMetric is a generic struct for metrics that can handle numeric values and time.Duration.

func (GenericMetric[T]) Compare

func (g GenericMetric[T]) Compare(operator MetricOperator, value float64) (bool, error)

Compare performs a comparison operation between the GenericMetric's value and another value.

type Metric

type Metric interface {
	Compare(operator MetricOperator, value float64) (bool, error)
}

type MetricOperator

type MetricOperator string
const (
	MetricEqOperator MetricOperator = "eq"
	MetricNeOperator MetricOperator = "ne"
	MetricGtOperator MetricOperator = "gt"
	MetricGeOperator MetricOperator = "ge"
	MetricLtOperator MetricOperator = "lt"
	MetricLeOperator MetricOperator = "le"
)

func ConvertToOperator

func ConvertToOperator(op string) (MetricOperator, error)

type Metrics

type Metrics interface {
	Find(name string) (Metric, error)
}

type NumericOrDuration

type NumericOrDuration interface {
	constraints.Integer | constraints.Float | time.Duration
}

NumericOrDuration is a constraint that limits the types to numeric types or time.Duration.

Jump to

Keyboard shortcuts

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